Problem ARRAY LENGTH

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lenniekuah
    New Member
    • Oct 2006
    • 126

    Problem ARRAY LENGTH

    Hullo Wonderful Friends
    I need your help, Please help me.

    I am using C#NET2008 to create Window Application using ARRAY. and ARRAY LENGTH
    I do encounter a very surprising error with ARRAY LENGTH and is very confused about it.

    I have declared an 2 Dimensional string Array Variable of [5,2]
    To determine the length of the array I use this coding : int intArrayLenth = (strArrayCus.Le ngth)
    and it produce the length of 10 instead of 5 as per declaration of [5,2]

    Here are the coding :

    Code:
    string[ , ] strArrayCus = new string [5, 2];
    
      private void   FillCustArray()
       {
                    
        // --- fill Customer Array for Listview column header text and width
        strArrayCus[0, 0] = "Cust  ID";
        strArrayCus[0, 1] = Convert.ToString(20);
    
        strArrayCus[1, 0] = "CompanyName";
        strArrayCus[1, 1] = Convert.ToString(100);
    
        strArrayCus[2, 0] = "ContactName";
        strArrayCus[2, 1] = Convert.ToString(80);
    
        strArrayCus[3, 0] = "Phone ";
        strArrayCus[3, 1] = Convert.ToString(30);
    
        strArrayCus[4, 0] = "Fax";
        strArrayCus[4, 1] = Convert.ToString(30);
      }  
    
    int intArrayLenth = (strArrayCus.Length)[B]<= 10error[/B]
  • Leito
    New Member
    • Apr 2010
    • 58

    #2
    It's logical because strArrayCus contains 10 (=5*2, for example 5 rows by 2 columns) cells.

    However, strArrayCus.Row s[0] should be equal to 2 (the first line contains 2 cells (=2 columns)).

    Comment

    Working...