20
Reply

Is it possbile to store all DataType in Array ?

Manoj Kalla

Manoj Kalla

8y
2.8k
1
Reply

    Yes, it is possible. For this you have to create an array of Object Type. Example: Object[] myObjects = Object[2]; myObject.Add(2); myObject.Add("String"); myObject.Add(true);

    Using Array of Object Type we can store any data type in object array

    Yes, Its possible by create array with OBJECT datatype. All datatype inherited in .NET from System.Object namespace.

    You can use ArrayList to store any type of data in the Array, however, I have never seen a requirement to create this array. You should avoid using ArrayList as it comes with the cost of performance which uses boxing/unboxing internally and that's how Microsoft introduced Generics.

    yes

    YES

    Yes, we can store by using array of Object Type. Object type array can store any dataType

    Yes

    through the arraylist it is possible.//creation of ArrayList ArrayList array = new ArrayList(); //Add method for adding values in ArrayList array.Add(1); array.Add("string"); customer c = new customer(); c.ID = 1; c.Name = "C# corner"; array.Add(c);

    through the arraylist it is possible.//creation of ArrayList ArrayList array = new ArrayList(); //Add method for adding values in ArrayList array.Add(1); array.Add("string"); customer c = new customer(); c.ID = 1; c.Name = "C# corner"; array.Add(c);

    yes

    By using obect array it is possible.........I am sure try this.

    int in = 2; string st = "hai"; object[] obj = new object[2]; obj[0] = in; obj[1] = st;

    in arraylist you can store

    array list can be used to store all data type in array

    ArrayList it is possible.

    Sorry ! You cannot store all things in an Array. Example : You cannot store any functions in an array.

    The Object Type is the ultimate base class for all data types in C# Common Type System (CTS). Object is an alias for System.Object class. So we can create object data type for storing all DataType in Array

    Yes, you can use object as the type for the array or list. Then any type can be stored in it.

    Yes, We can use var datatype