11
Reply

variable unassigned

Ask a question
Ben

Ben

14y
3.6k
1
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)