Showing posts with label anonymous. Show all posts
Showing posts with label anonymous. Show all posts

Wednesday, September 5, 2012

anonymous datatype in .net



we can declare anonymous datatype using var
var a=10;
 declaring arrays using var

integer array
var a =new int[]{1,2,3,4,5}

console.writeline(a[2].tostring())
O/P
3
string array

 var a=new string[]{"hi","hello"}

console.writeline(a[1].tostring())

O/P

 hello

we can also copy methods into anonymous datatype also

ex:

func method1 = delegate (int a,int b) { return a+b;};

Now we can copy this method into Anonymous

Var d= new { meth=methode1}

console.writeline(d.meth(1,2));

O/P

3