How to check value in IF statement..
-
Hi guyzz.. i have a doubt may be i have a query in C# coding and the query returns a string... Now i need to perform a check using if statement, my check is that if the query returns any string value then grant permission else access denied... Now my doubt is how do i specify "return any string value" in the if condition... plz advice...
If(query == ?????)
{
permission granted
} -
Hi guyzz.. i have a doubt may be i have a query in C# coding and the query returns a string... Now i need to perform a check using if statement, my check is that if the query returns any string value then grant permission else access denied... Now my doubt is how do i specify "return any string value" in the if condition... plz advice...
If(query == ?????)
{
permission granted
} -
Either check
if (query.Length > 0)
orif (query != string.Empty)
. If yourquery
variable can benull
then you can checkif(query != null)
. Good luck! :) so your statement should read:if (query != null)
{
if (query.Length > 0)
//permission granted
} -
Thanx.. its actually very silly doubt... the logic dint strike me as im a new comer in programming... Thanx alot.. regards, tash
to check if a string is null or empty, usually
if(!String.IsNullOrEmpty(value))
should be used. This checks for both empty and null strings. -
to check if a string is null or empty, usually
if(!String.IsNullOrEmpty(value))
should be used. This checks for both empty and null strings. -
welcome!! :)
-
to check if a string is null or empty, usually
if(!String.IsNullOrEmpty(value))
should be used. This checks for both empty and null strings. -
Happens buddy!!! All in a day's work.
-
Hi guyzz.. i have a doubt may be i have a query in C# coding and the query returns a string... Now i need to perform a check using if statement, my check is that if the query returns any string value then grant permission else access denied... Now my doubt is how do i specify "return any string value" in the if condition... plz advice...
If(query == ?????)
{
permission granted
}if (!string.IsNullOrEmpty(query))
{
// premission granted
}.45 ACP - because shooting twice is just silly
-----
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001