Array

Array means collection of similar Data Types or Store Collection of similar Data Types Value in Array.

Ex:
  1. int[] no = new int[2];
We declare or Create integer type array as "no". We can store only integer value not like string,bool etc.
  1. int[] no = new int[2];
  2. no[0] = 9080;
  3. no[1] = 8090;
We want to store any data type value other than int then show error as

program

But we can store different data type value in array as;
  1. namespace Array
  2. {
  3. class Program
  4. {
  5. static void Main(string[] args)
  6. {
  7. bool b = true;
  8. object[] obj = new object[3];
  9. obj[0] = 1;
  10. obj[1] = "Vishu";
  11. obj[2] = b;
  12. Console.WriteLine("value of Array 0 as" + " " + obj[0] + " ");
  13. Console.WriteLine();
  14. Console.WriteLine("and value of array 1 as" + " " + obj[1] + "");
  15. Console.WriteLine();
  16. Console.WriteLine("and value of array 2 as" + " " + obj[2] + "");
  17. Console.ReadLine();
  18. }
  19. }
  20. }
Object

Object is Reference Type , you can assign any value type and reference type variable to object data type.

Output

output