Ben

Ben

  • NA
  • 5
  • 0

variable unassigned

Jul 20 2010 12:15 PM
I have created a very simple little program that adds a value to a string variable once tested if its empty.... My problem is that VS 2010 tells me that the variable is uns=assigned in my if conditional parameters. I have done java and c++ for a number of months now with little trouble so this is boggling me...

Here is my code:

 static void Main(string[] args)
{
string anotherStr;

if (anotherStr == "")
{
anotherStr = "bye";
}

Console.ReadKey();

}
 
I appreciate the help

Answers (11)