Can you store multiple data types in System.Array?
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
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 |
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 |
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 |
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 |
Can c# inherit multiple classes?
When a new instance of a type is created, what is the type of method implicitly called?
How big is an int16?
Is and as keyword in c# net?
For read-only operation which property you have to designated?
What's the difference between class and object?
What is data binding c#?
What is Fragmentation and its Types?
What?s class SortedList underneath?
what are the differences between a class and structure
What framework is used for performance testing/load testing?
interface a { Method1() Method2() } class b: a { override Method1() override Method2() } what will happen & why?
Visual Basic (800)
C Sharp (3816)
ASP.NET (3180)
VB.NET (461)
COM+ (79)
ADO.NET (717)
IIS (369)
MTS (11)
Crystal Reports (81)
BizTalk (89)
Dot Net (2435)
Exchange Server (362)
SharePoint (720)
WCF (340)
MS Office Microsoft (6963)
LINQ Language-Integrated Query (317)
WPF (371)
TypeScript (144)
Microsoft Related AllOther (311)