operator != cannot be applied to string and int [Resolved]

Posted by Oswaldlily under ASP.NET on 3/14/2012 | Points: 10 | Views : 1539 | Status : [Member] | Replies : 1
string s="name";
if(string !=0)
{

}

facing this error
operator != cannot be applied to string and int in C#
How to overcum




Responses

Posted by: Hmanjarawala on: 3/14/2012 [Member] Bronze | Points: 50

Up
0
Down

Resolved
Hi,
it can be either:

string s="name";
if(s != "0")
{

}

or

string s="name";
if(s.Length !=0)
{

}


Himanshu Manjarawala
Sr. Software Engineer@AutomationAnywhere
http://fieredotnet.wordpress.com/

Oswaldlily, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response