Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Can you store multiple data types in System.Array?

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


Please Help Members By Posting Answers For Below Questions

I need code to connect ohter systems in the LAN and i want to display my website image over there and i want explain as a admin through phone. So i need code to access other system using C-Sharp. Any one please help me.Please give me the code. Advace thanks.

1846


how to sort an array in c#

938


What namespace is list in c#?

863


What is public or shared assemblies ?

949


What does a constructor do c#?

869


What is a string in c#?

831


What are the advantages of using delegates in c#?

863


How objects are stored in memory?

929


Distinguish between continue and break statement?

996


How to create events for a control? What is custom events? How to create it?

939


Illustrate the differences between the system.array.copyto() and system.array.clone()?

915


Does c# support const methods, properties, or events?

916


What is the difference between structure and class in c#?

895


How to reduce image resolution in C#?

1009


What is sorted list in c#?

841