Introducing Radical.sh

Forget Code launches a powerful code generator for building API's

Get upper bound in an Array in C#

Example:

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text.RegularExpressions;
  5.  
  6. namespace ForgetCode
  7. {
  8. public class MainClass
  9. {
  10. public static void Main()
  11. {
  12. string[,] a = {{"hi","hello"},{"aa","ggg"}};
  13. for (int i = 0; i <= a.GetUpperBound(0); i++)
  14. {
  15. string s1 = a[i, 0];
  16. string s2 = a[i, 1];
  17. Console.WriteLine("{0}, {1}", s1, s2);
  18. }
  19. }
  20. }
  21. }


Output:
  1. hi, hello
  2. aa, ggg