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
Ho we can see assembly information?
What is overloading with example?
Which debugging tools you can use in the .NET ssSDK?
What is generic types in c#?
What is void method?
What is difference between code access and role based security?
Give some examples of commonly used i/o classes?
Can datetime be null c#?
Can dictionary have duplicate keys c#?
What is iqueryable in c#?
Constructor to an arbitrary base constructor?
What is continue in c#?
Why is aws serverless?
What are sessions in c#?
What is the difference between finally and finalize block?