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 use of readkey in c#?
How do I move from one form to another in c#?
What is the difference between const and static read-only?
How to use the sreamReader class to read form a text file?
Enlist some of the properties of a thread class?
What is int32 maxvalue?
What is data hiding in c#?
Explain about CTS?
What is assembly c#?
What is object array in c#?
When a Static Constructor is called in a Class?
What is difference between override and new in c#?
Name the control which cannot be placed in mdi?
What are Uses of CLR
Why do we use interfaces in c#?