Can you store multiple data types in System.Array?

Answer Posted / alok yadav

Yes, its possible try the below sample
replace manageAdvertisement with your class

System.Array ar=Array.CreateInstance(Type.GetType
("System.Object"),3);
ar.SetValue("asdfas",0);
ar.SetValue(1, 1);
ManageAdvertisement mg=new ManageAdvertisement();
mg.AdvertisementDesc="123124";
ar.SetValue(mg, 2);
foreach (object obj in ar)
{
Response.Write( obj.GetType() +"<br>");

}

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between public, static, and void?

654


Can an abstract class inherit from another abstract class c#?

724


What does ienumerable mean?

672


What is xor operator in c#?

705


What is the difference between interface and inheritance in c#?

669


When do you generally use a class over a struct?

720


Can I fly with a loop recorder?

656


What is difference between function and method in c#?

628


What is the do while loop code?

667


Why do I get an error (cs1006) when trying to declare a method without specifying a return type?

709


How many static constructors are allowed in a class?

654


What is virtual in c#?

651


How do you sort a list in c#?

650


What are All kind of access specifiers for a class and for methods

811


Why do we use lambda expression in c#?

680