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
Define an escape sequence, name few strings in escape sequence?
What is a c sharp?
Explain how is the dll hell problem solved in .net?
What is a generic in c#?
How string definitions will prevent escaping on backslashes in C#?
Why to use “finally” block in c#?
What is cshtml extension?
Is c# front end or back end?
Why do we use constructors in c#?
What is the difference between hashtable and dictionary?
What is xml comments in c#?
Explain About namespaces
What are mutable and immutable types in c#?
What are most desktop applications written in?
Explain types of comment in c# with examples