Sunday, 15 September 2013

c# - array[1] does not show up as null -


ifprofile = "text">

I am having trouble getting the value of the input array [1] to come in the form of zero value for my statement.

Here's a look at the code:

  Fixed zero GetInput () {string input = Console.ReadLine (); String [] inputArchive = input Split (new four [] {'}}, string split option. RemoveEmptyEntries;); Switch (input too [0]) {case "exit": system.console. Video line (input [0]); Console.WriteLine ("Exiting ..."); break; Case "Help": System.Sc. The white line (input [0]); help(); GetInput (); break; Case "Openwall": if (input is [1]! = Null); {System.Console.WriteLine (InputArray [0] + "+++InputArere [1]); FileExt = InputArere [1]; Open Files (); GetInput ();} Breakdown;}}   

Now I have tried in many ways if (input array [1]! = Tap); but nothing seems to work, so I know that in my knowledge of programming there is something that I just remember Is coming.

I am getting this error: the index was out of range of array.

All help is appreciated!

Before you check, you need to test the length of the array

  if (inputArray [1]! = Null)   

To do something like

P>

  if (inputArray.Length & gt; 1 & amp; input array [1]! = Null)    

As the comments,

  if (inputArray.Length> 1)   

As more accurate code for inputArray [1] will be tested! = Zero will never be true.

No comments:

Post a Comment