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. How to handle null values when reading array

How to handle null values when reading array

Scheduled Pinned Locked Moved C#
questiondata-structurestutorial
6 Posts 4 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.
  • O Offline
    O Offline
    onetreeup
    wrote on last edited by
    #1

    I have an array that I am converting values from. It is a comma delimited file, and has some null values in it. While I am reading the file to convert, how can I handle the null values?

    C L S 3 Replies Last reply
    0
    • O onetreeup

      I have an array that I am converting values from. It is a comma delimited file, and has some null values in it. While I am reading the file to convert, how can I handle the null values?

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      with code ? I don't see what the question is. If you are writing code to convert values, can't you check for null first ? It's up to you if you skip a null, or insert a default value in it's place.

      Christian Graus Driven to the arms of OSX by Vista. "I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )

      O 1 Reply Last reply
      0
      • C Christian Graus

        with code ? I don't see what the question is. If you are writing code to convert values, can't you check for null first ? It's up to you if you skip a null, or insert a default value in it's place.

        Christian Graus Driven to the arms of OSX by Vista. "I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )

        O Offline
        O Offline
        onetreeup
        wrote on last edited by
        #3

        I apologize if my question seemed stupid. I am looking for assistance with the code, which is why I am in the C# message board. :((

        C 1 Reply Last reply
        0
        • O onetreeup

          I have an array that I am converting values from. It is a comma delimited file, and has some null values in it. While I am reading the file to convert, how can I handle the null values?

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          impossible to answer: you hardly described the input and didn't say a thing about the output. explain more, AND give some examples. :)

          Luc Pattyn [Forum Guidelines] [My Articles]


          Avoiding unwanted divs (as in "articles needing approval") with the help of this FireFox add-in


          1 Reply Last reply
          0
          • O onetreeup

            I apologize if my question seemed stupid. I am looking for assistance with the code, which is why I am in the C# message board. :((

            C Offline
            C Offline
            Christian Graus
            wrote on last edited by
            #5

            If you posted some code, then perhaps we could assist you with your code. As it stands, we're struggling to understand what the hell you're talking about. If you have null values coming in ( we don't even know where from ), then you can check for them, surely ? Perhaps not, in your situation, but you've not come close to making that clear.

            Christian Graus Driven to the arms of OSX by Vista. "I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )

            1 Reply Last reply
            0
            • O onetreeup

              I have an array that I am converting values from. It is a comma delimited file, and has some null values in it. While I am reading the file to convert, how can I handle the null values?

              S Offline
              S Offline
              Sibugathulla
              wrote on last edited by
              #6

              Please Don't Worry You can Solve NullException problem Using one of the two methods :) . 1) If you create Your own Array Please Initalize it.

              List<String> strArray= new List<String>();
              strArray.Add("Code Project");

              Here new List<String>(); is important

              1. If you get the list from any where else You can check for null as follows

              if(strArray != null)
              if(strArray.Count >0)
              MessageBox.Show(strArray[0]);

              SibGeth

              Something Differentâ„¢

              www.SibGeth.net

              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