Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. string array

string array

Scheduled Pinned Locked Moved C#
data-structureshelpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mazdak
    wrote on last edited by
    #1

    I add this member to mny class:

    private string[][] lines;

    Then in one function I use this:

    for(int i=1 ; i < myDataView.Table.Rows.Count ; i++)
    {
    for(int j=0 ; j < myDataView.Table.Columns.Count ; j++)
    {
    lines[i][j]= "mazy";
    }
    }

    But for the line 'lines[i][j]= "mazy";' I got unhandled error: Object reference not set to an instance of an object. What I missed for string[][]? Thanks Mazy "So,so you think you can tell, Heaven from Hell, Blue skies from pain,... How I wish,how I wish you were here."
    Wish You Were Here-Pink Floyd-1975

    S 1 Reply Last reply
    0
    • M Mazdak

      I add this member to mny class:

      private string[][] lines;

      Then in one function I use this:

      for(int i=1 ; i < myDataView.Table.Rows.Count ; i++)
      {
      for(int j=0 ; j < myDataView.Table.Columns.Count ; j++)
      {
      lines[i][j]= "mazy";
      }
      }

      But for the line 'lines[i][j]= "mazy";' I got unhandled error: Object reference not set to an instance of an object. What I missed for string[][]? Thanks Mazy "So,so you think you can tell, Heaven from Hell, Blue skies from pain,... How I wish,how I wish you were here."
      Wish You Were Here-Pink Floyd-1975

      S Offline
      S Offline
      SimonS
      wrote on last edited by
      #2

      You aren't initialising the jagged array. MSDN: Before you can use myJaggedArray, its elements must be initialized From the look of your code, you might find a multidimensioned array more useful. Here's the construct: private static string[,] lines= new string[10,100]; Cheers, Simon X-5 452 rules.

      M 1 Reply Last reply
      0
      • S SimonS

        You aren't initialising the jagged array. MSDN: Before you can use myJaggedArray, its elements must be initialized From the look of your code, you might find a multidimensioned array more useful. Here's the construct: private static string[,] lines= new string[10,100]; Cheers, Simon X-5 452 rules.

        M Offline
        M Offline
        Mazdak
        wrote on last edited by
        #3

        Thanks,It works now:) Mazy "So,so you think you can tell, Heaven from Hell, Blue skies from pain,... How I wish,how I wish you were here."
        Wish You Were Here-Pink Floyd-1975

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups