string problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to use an if statement to obtain a return value to use somewhere else in my program. Can you look at this code and tell me what needs to be added to the code to keep from getting an unassigned local variable sortParameter error



public string SortParameter(



string sortParamete

if (fiscalYearCheck.Checked == true



sortParameter = "wo11"



else if (custCheck.Checked == true



sortParameter = "wopm2"



return sortParameter





Thanks



Dav
 
Dave,

You can just declare your variable like this:

string sortParameter = null;

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Dave Bailey said:
I am trying to use an if statement to obtain a return value to use
somewhere else in my program. Can you look at this code and tell me what
needs to be added to the code to keep from getting an unassigned local
variable sortParameter error.
 
Dave,

Try doing this;

string sortParameter = null;

this way the string is assigned a value. thus no error

HTH
Marco
Dave Bailey said:
I am trying to use an if statement to obtain a return value to use
somewhere else in my program. Can you look at this code and tell me what
needs to be added to the code to keep from getting an unassigned local
variable sortParameter error.
 
Back
Top