Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


Can you store multiple data types in System.Array?

Answers were Sorted based on User's Feedback



Can you store multiple data types in System.Array?..

Answer / payal mehta

No,we cannot store multiple datatype in Array.we can store
similar datatype in Array,but i think that we can store in
ArrayList class in c#.

Is This Answer Correct ?    8 Yes 8 No

Can you store multiple data types in System.Array?..

Answer / 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

Can you store multiple data types in System.Array?..

Answer / srikar

No

Is This Answer Correct ?    1 Yes 1 No

Can you store multiple data types in System.Array?..

Answer / ajeet singh

yes, we can store different data type in System.array.
for do this we have to create the array of OBJECT type.....

Is This Answer Correct ?    0 Yes 0 No

Can you store multiple data types in System.Array?..

Answer / ankur

yes we can store multiple datatype in system.array in c#

Is This Answer Correct ?    0 Yes 0 No

Can you store multiple data types in System.Array?..

Answer / suyash

ideally we don't,, but we can....
we can do this by declaring object in array which can be
used for different data types!!!

Is This Answer Correct ?    0 Yes 0 No

Can you store multiple data types in System.Array?..

Answer / shamjeet

yes,ofcourse
System.Array is of Object Type
eg:
int a =10;
float b=2.03;
string c = "yes"
object[] val = new object[3];
val[0] = a;
val[1] = b;
val[2] = c;

Is This Answer Correct ?    0 Yes 0 No

Can you store multiple data types in System.Array?..

Answer / michael

No you can't ArrayList stores object. So if you use something like this
ArrayList arr = new ArrayList();
arr.Add(56);
arr.Add("ASDf");

you are still storing objects, 56 is object, ASDf is an object

Is This Answer Correct ?    0 Yes 0 No

Can you store multiple data types in System.Array?..

Answer / surya

No you can not. But if you use System.Collection.ArrayList
then you can store multiple data types in ArrayList but not
in case of System.Array.

Is This Answer Correct ?    3 Yes 5 No

Can you store multiple data types in System.Array?..

Answer / srivathsan

i guess you cannot do that in a list too. because an array
list is also type safe.
eg:

List<int> arraylist = new List<int>();

the arraylist can contain only integer items.You cannot
store an item that is not an integer type in the arraylist.

Is This Answer Correct ?    4 Yes 7 No

Post New Answer

More C Sharp Interview Questions

What is the difference between static and private constructor in c#?

0 Answers  


What are the Uses of CLR

0 Answers   TCS,


What is the difference between early binding and late binding in c#?

0 Answers  


What is a jagged array?

0 Answers  


What is an inheritance ?Give an example in which inheritance is used?

0 Answers   Siebel,


What is the difference between values and reference types?

0 Answers   Alcatel-Lucent,


Explain briefly the difference between value type and reference type?

0 Answers   Accenture,


What are the Types of optimization and name a few and how do u do?

0 Answers   BirlaSoft,


How will you deploy the dll file in gac?

0 Answers  


int i = 1; int j = 1; System.Console.WriteLine(i == j); System.Console.WriteLine(i.ToString() == j.ToString()); System.Console.WriteLine((object)i == (object)j); Give the sample code above, what is the output to the console?

5 Answers  


Can I use ReaderWriterLock instead of Monitor.Enter/Exit for Threading?

0 Answers   HCL,


Can you override private virtual methods?

4 Answers  


Categories