Showing posts with label c#. Show all posts
Showing posts with label c#. Show all posts

Monday, 4 February 2013

WCF returning Json data

in the .net world, we need to get the data by getting the property d like this:

var cust = data.d[0];

var cust = data.d.firstname;

this won't work: var cust = data[0];

Thursday, 3 January 2013

C# HashSet

A HashSet holds a set of objects, in a way that it allows you to easily and quickly determine whether an object is already in the set or not.

C# HashSet class preserves the order of the elements.

The only catch of HashSet is that there is no access by indices.

Wednesday, 5 December 2012

C# "??" Operator

The "??" operator is called the null-coalescing operator and is used to define a default value for a null able value types as well as reference types. It returns the left-hand operand if it is not null; otherwise it returns the right operand.

objNullable = objNullable ?? new objMyObject();

Thursday, 15 March 2012

Multiple Main Methods in C#

Specify the Startup object in the Project Properties, Application tab.


Make sure the Main() method takes no parameters, or a single array of string ("string", not "String").  It should also returns nothing, or an int.  Otherwise, the main method(s) won't be shown in the dropdown list.



        static void Main(string[] args)
        {
 
        }

        static void Main()
        {
 
        }