what is an anonymous class?

Answer Posted / narasimha

hi ,
look into this


Anonymous type is the type that is created anonymously.
Anonymous type is a class that is created automatically by
compiler in somewhere you can’t see directly while you are
declaring the structure of that class. Confusing? Let me
show you one example.

view plaincopy to clipboardprint?

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

namespace ConsoleApplication1 {
class Program {
static void Main(string[] args) {
Person _person = new Person { ID = 1, FirstName
= "Michael", LastName = "Sync" };
Console.WriteLine("Name: {0} {1}", _person.FirstName,
_person.LastName);
Console.ReadLine();
}
}
public class Person {
public int ID { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
}
}

Is This Answer Correct ?    0 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are keywords give examples?

556


How variables are stored in memory?

516


Why is singleton class used?

498


Can a constructor have different name than a class name in java?

572


What is the use of math abs in java?

525






What is multithreading in java?

518


How is abstraction implemented in java ?

517


What is the final keyword denotes?

653


What is difference between variable declaration and definition?

488


How do you sort in java?

568


Can a abstract class be defined without any abstract methods?

526


How to disable caching on back button of the browser?

504


How do you remove an object from an arraylist in java?

443


What is variable explain with example?

545


what is the final keyword denotes in java?

561