Click here to Skip to main content
15,901,373 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

I have a wcf service which was returning the output of a method. i am checking weather it is empty or not



C#
if(objRec.System[]="" )
{

}



It was throwing me a error "syntax error; value expected"....in "]"


Regards,
Basha
Posted
Updated 29-Nov-11 6:38am
v5

objRec.System[] is not a valid object reference; add an index value to tell the compiler which element you are referring to.
 
Share this answer
 
Comments
inayat basha 29-Nov-11 12:44pm    
ya it has so many values inside it, but one of the value i am spliting so need to check weather it is empty or not
C#
if(objRec.System[]="" )
{

}


if you are looking for a value with in the array you should have an array index, or else if you would like to check if the array is empty or not do the following.


C#
if(objRec.System.Count == 0 )
{

}



Hope it helps!!
 
Share this answer
 
Comments
inayat basha 29-Nov-11 12:45pm    
ya it has so many values inside it, but one of the value i am spliting so need to check weather it is empty or not..but

if(objRec.System.Count == 0 )
{

} is not working
Sergey Alexandrovich Kryukov 29-Nov-11 12:49pm    
What's "not working". You already got answers, now it looks like you need to learn the very basics of programming from scratch as you apparently did not get it. Do it until it's too late.
--SA
Sergey Alexandrovich Kryukov 29-Nov-11 12:50pm    
Vote 4. It's correct, but don't use "", use string.Empty.
--SA
inayat basha 29-Nov-11 12:51pm    
if i put objRec.System.Count == 0 it's throwing error
so i put objRec.System.length < 0 i put .... thx for ur reply
VallarasuS 29-Nov-11 12:58pm    
Happy to hear you have resolved it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900