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 / neeraj kumar shrivastwa

If you take an array of object, you can store multiple data
type in an array.
object[] obj = new object[4];
obj[0]=1;
obj[1]="Neeraj";
obj[2]=true;
obj[3]=System.DateTime.Now;

Is This Answer Correct ?    53 Yes 5 No

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

Answer / satyadarshi

No,we cannot store multiple datatype in Array.we can store
similar datatype in Array.

Is This Answer Correct ?    39 Yes 17 No

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

Answer / tsahi

Yes you can, if you have an object array. since
System.Object is the base class of all other types, an item
in an array of Objects can have a reference to any other
type of object.

Is This Answer Correct ?    23 Yes 1 No

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

Answer / vishalsharma

No.

Is This Answer Correct ?    41 Yes 21 No

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

Answer / vishal shah

What payal has mentioned is absolutely right. Array doesnt
store different datatypes. but ArrayList can store
different types of datatype in a single object.

Is This Answer Correct ?    12 Yes 2 No

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

Answer / vishal

Ok, so here is the catch:

An array of objects can store different datatype members -
object[] ar = new object[3];
ar[0] = "test";
ar[1] = 56;

An arraylist can also be used for this purpose -
ArrayList arr = new ArrayList();
arr.Add(56);
arr.Add("ASDf");

And a generic list too can be used for this purpose -
List<object> llst1 = new List<object>();
llst1.Add(56);
llst1.Add("ASDf");

Is This Answer Correct ?    6 Yes 1 No

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

Answer / abc

yes, if array type is specified as object

Is This Answer Correct ?    4 Yes 0 No

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

Answer / uma

S, Use Generic lists.

Is This Answer Correct ?    5 Yes 4 No

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

Answer / ann

no..we cant ..only similar data types in an array.
but we can store in ArrayList

Is This Answer Correct ?    6 Yes 5 No

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

Answer / harry

We Can Store Multiple datatypes in array by taking array as
object

Dim myarr(8) As Object
myarr(3) = "fff"
myarr(4) = 45645

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More C Sharp Interview Questions

Explain About CLS?

0 Answers   Microsoft,


What is different between Implicit conversion and Explicit conversion in C#?

0 Answers  


What is file extension of webservices?

0 Answers  


What is thread.sleep()?

0 Answers  


can you allow a class to be inherited, but prevent the method from being over-ridden?

0 Answers   Siebel Systems,






What is the difference between // comments, /* */ comments and /// comments?

0 Answers  


How do I format in c#?

0 Answers  


Why is dll used?

0 Answers  


What is data quality assurance?

0 Answers  


can you overload a method of class A in Class B if it is derived class of A?If it is yes tell me how is it possible?

4 Answers   Mphasis, Ness Technologies,


What is streamreader/streamwriter class?

0 Answers  


Why do we use virtual methods in c#?

0 Answers  


Categories