Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

String to bool conversion

Status
Not open for further replies.

uzzie123

Technical User
Mar 7, 2007
21
0
0
CA

Hi,

I am trying to create a condition statement. But when executing this block of code I receive an error stating that string to bool conversion cannot be done implicitly.

userInput = Console.ReadLine();

if(userInput = "")
{

userGravity = 9.80d;

Console.WriteLine("Gravity has been defaulted to 9.8 m/s^2");
}
else
{
userGravity = double.Parse(userInput);
}

userGravity = double.Parse(userInput);

Can someone please exaplaim the problem and show me the right way!

Thx.
 
== is for comparison as it is an overload for .Equals()

= assigns a value to the variable
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top