Can you store multiple data types in System.Array?

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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why to use “using” in c#?

559


What exactly happens when we debug and build the program?

2177


What does return do in for loop?

484


Which language is used for desktop application?

486


Is array ienumerable c#?

471






Can you inherit multiple classes in c#?

501


What is the use of protected in c#?

499


How is the syntax written to inherit from a class in C#?Give an example ?

543


Which of these string definitions will prevent escaping on backslashes in c#?

573


Explain the role of Garbage collector and its generations?

523


What are sessions in c#?

496


1. Describe page life cycle?

1582


Is c# code is managed or unmanaged code?

493


What is sqladapter c#?

532


What are the 3 types of comments in c#?

525