views:

98

answers:

2
if ((file.Exists) ? 
lblresults.Text = "the file is there" : 
lblresults.Text = "the file is not there");

I keep getting the error stating cannot implicitly convert string to bool

any help would be great, thanks.

+3  A: 

try this:

lblResults.Text = file.Exists ? "the file is there" : "the file is not there";

Basically you don't need the if.

John Buchanan
thank you! didn't expect an answer so fast.
Pete
+1  A: 

It expects a bool back. Try this:

lblResult.Text = ((file.Exists) ? "the file is there" : "the file is not there");
GrayWizardx
thank you! didn't expect an answer so fast.
Pete