Answer Posted / sudhir sheoran
The answer is yes and no.
Ideally array is collection of single data types
E.g :-
array [] arr = new int [10];
it will store only int because datatype is defined
as int in this case.
In case of some particular requirements array can be used
to store diff data types. But in this case array has
to be declared as object array
E.g:-
class Test
{
public static void Main()
{
object[] arr = new object[10];
arr[0] = 1;
arr[1] = "Hello";
Console.WriteLine(arr[0]);
Console.WriteLine(arr[1]);
Console.ReadLine();
}
}
This is successfully complied.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is the difference between int and int in c#?
What is cls, cts and clr in net?
Is c# still popular?
What is a race condition?
What is strong name in c# and how can we use it?
Why we use get and set method in c#?
Can we maintain state in webservice?
Can you use all access modifiers for all types?
How does it work?
Is static thread safe?
What is the difference between structure and class in c#?
Where do I put dll files?
What does an indexer do?
Explain the advantage of using system.text.stringbuilder over system.string?
What is a multicast delegate in c#?