Click here to Skip to main content
15,887,746 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 calling a field in that like this

C#
label.text = objRec.System[].cLLI ;



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


Regards,
Basha
Posted
Updated 25-Nov-11 23:45pm
v2

You have to put something in between two square brackets e.g. [0] [i]
 
Share this answer
 
Comments
inayat basha 26-Nov-11 5:49am    
But i have 10 fields in that method..then how can i write it
Mehdi Gholam 26-Nov-11 5:53am    
Pick a number 0 to 9 which corresponds to the field you want.
inayat basha 26-Nov-11 5:54am    
thx u let me check..
RaisKazi 26-Nov-11 5:56am    
My 5.
Mehdi Gholam 26-Nov-11 5:57am    
Cheers
What I can see from your example is that objRec.System is an IList or Array type, so you should specify the index of the item your want the cLLI Property from.
For example:
C#
label.text = objRec.System[0].cLLI ; // Gets the first item in the list. If there are no items throws a NullReferenceException.
 
Share this answer
 
v2
Comments
inayat basha 26-Nov-11 5:50am    
hi,

sorry...cLLI is a field in that method, i have 9 more fields, then how can i write for others (lable2,lable3)..

Thx

Thanks
Sander Rossel 26-Nov-11 6:30am    
label1.Text = objRect.System[0].cLLI;
label2.Text = objRect.System[1].cLLI;
label3.Text = objRect.System[2].cLLI;
...
Or did you mean this?
label1.Text = objRect.System[0].cLLI;
label2.Text = objRect.System[0].OtherField;
label3.Text = objRect.System[0].OtherOtherFields;

Or maybe you could do it in a for or foreach loop. Depends on your situation.
RaisKazi 26-Nov-11 5:56am    
My 5.
Sander Rossel 26-Nov-11 6:10am    
Thanks Rais :)
Mehdi Gholam 26-Nov-11 5:57am    
5'ed

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