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's the difference between System.String and System..StringBuilder in C#?
How do you create dlls in .NET
What is msil in c#?
What is a delegate? Explain.
What is the difference between dataset and datatable in c#?
Is stringbuilder thread safe c#?
What is the difference between namespace and class in c#?
What is a struct in C#?
what is an exception in .net?
Is c# and c same?
What is stringwriter c#?
What is int32?
What is the use of command builder?
What is the purpose of a constructor in c#?
Why do we need to override in c#?