Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

Browse by Tags · View All
BRH 58
#ASP.NET 55
ASP.NET 50
#DOTNET 49
.NET 40
WCF 21
DOTNET 12
c# 8
windows azure 7
SILVERLIGHT 7

Archive · View All
April 2011 9
March 2011 9
February 2011 8
December 2010 7
November 2010 5
September 2010 5
August 2010 5
May 2011 4
October 2010 4
January 2011 2

Anonymous types in C# 3.0

Oct 6 2010 1:46PM by Dhananjay Kumar   

anonymous types is the new feature in c# 3.0 . Which allows to create a class on the fly without any name. This is very useful while fetching value from LINQ query


  1. Anonymous types are new feature being added in C# 3.0.
  2. These are data types being generated on the fly at the run time.
  3. These data types are generated through complier rather than explicit class definition.

Program.cs

using System;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Text;

namespace ConsoleApplication17
{
    classProgram
    {
        staticvoid Main(string[] args)
        {

            varMyAnonClass = new
            {
                Name = "Scott",
                Subject  ="ASP.Net"

            };
            Console.WriteLine(MyAnonClass.Name);
            Console.Read();
        }
    }
}

Output

clip_image002

A class without name is being generated and assigned to implicitly type local variable

How it works internally?

1. For an anonymous type syntax compiler generates a class.

2. Properties of the complier generated class are value and data type given in declaration.

3. Intellisense supports anonymous type class properties.

clip_image003

4. Properties of one anonymous type can be used in declaration of another anonymous type.

varSecondAnoynClass = new
{
    info = MyAnonClass.Name + MyAnonClass.Subject
};

Program.cs

using System;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Text;

namespace ConsoleApplication17
{
    classProgram
    {
        staticvoid Main(string[] args)
        {
            varMyAnonClass = new
            {
                Name = "Scott",
                Subject = "ASP.Net"
            };
            Console.WriteLine(MyAnonClass.Name);
            Console.Read();
            varSecondAnoynClass = new
            {
                info = MyAnonClass.Name + MyAnonClass.Subject
            };
            Console.WriteLine(SecondAnoynClass.info);
            Console.Read();
        }
    }
}

Output

clip_image006

Tags: #DOTNET, DOTNET, #ASP.NET, ASP.NET, c#, BRH,


Dhananjay Kumar
49 · 4% · 1198
0
Liked
 
0
Lifesaver
 
0
Refreshed
 
0
Learned
 
0
Incorrect



Submit

Your Comment


Sign Up or Login to post a comment.

    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]