Write C# Program to Demonstrate Jagged Arrays


Introduction

I have used Visual Studio 2012 for debugging purpose. But you can use any version of visul studio as per your availability.


techstudy.org

Kindle Paperwhite High Resolution Display Tablet | Rs. 9999

  1. using System;
  2. class Program
  3. {
  4. static void Main()
  5. {
  6. int[][] jagArray = new int[3][];
  7. jagArray[0] = new int[2];
  8. jagArray[0][0] = 12;
  9. jagArray[0][1] = 13;
  10. jagArray[1] = new int[1] { 12 };
  11. jagArray[2] = new int[3] { 15, 16, 17 };
  12. for (int i = 0; i < jagArray.Length; i++)
  13. {
  14. int[] innerArray = jagArray[i];
  15. for (int a = 0; a < innerArray.Length; a++)
  16. {
  17. Console.WriteLine(innerArray[a] + " ");
  18. }
  19. }
  20. Console.Read();
  21. }
  22. }

Result

C# language techstudy

     





Related Topics


Responses




Popular Posts

Facebook

Founded in 2016, Tech Study passionately delivers stylish and dynamic innovative information to programmer and technology lovers. http://www.techstudy.org/.