Wednesday, 24 June 2015

what is an array in c#?


Design Page : -
  <asp:Label ID="lblValue" runat="server" ForeColor="Red" />

Code Behind : -
// Multi dimensional Array
            string[] arr = new string[] { "abc", "def", "ghi", "jkl" };
            int[] num1 = new int[] { 0, 1, 2, 6, 6, 7, 4, 4, 4, 3 };

            lblValue.Text = arr[0] + " " + arr[1] + " " + arr[2] + " " + arr[3];

            // Single dimensional Array
            int[] num = new int[10] { 0, 1, 2, 6, 6, 7, 4, 4, 4, 3 };
            string[] j = new string[5] { "a", "b", "c", "d", "e" };
            lblValue.Text = Convert.ToString(abc(num));


            string[,] h = new string[3, 2] { { "Deepak", "Sharma" }, { "Hemal", "Kumar" }, { "Mahesh", "Yadav" } };

            lblValue.Text = h[0, 0] + " " + h[0, 1] + " " + h[1, 0] + " " + h[1, 1] + " " + h[2, 0] + " " + h[2, 1];

Mehod : -
  private int abc(int[] a)
        {
            return a[5] * 2;
        }

No comments:

Post a Comment

Thanks for comments.