Click here to Skip to main content
15,899,314 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have a scenario where i have to get the field (Field name: Assignees) values and display. In the documentation it is written as shown below:

C#
List<Int32> multiObject = ((List<Int32>)favoriteDocumentsField.Value);
     for (int index = 0; index < multiObject.Count; index++) {
          Int32 docID = multiObject[index];
          Console.WriteLine("Artifact: {0} Field: {1} Value: {2}", employee.ArtifactID, favoriteDocumentsField.Name + " Object " + index, docID);
     }


I am not using Console.WriteLine as i am using this logic in API. So, as per my code i have changed as shown below:

C#
List<Int32> multiObject = ((List<Int32>)favoriteDocumentsField.Value);
string EmailAddress="";
     for (int index = 0; index < multiObject.Count; index++) {
          Int32 docID = multiObject[index];
EmailAddress += employee.ArtifactID + favouriteDocumentsField.Name + "Object: " + index, docID);
               }


I am getting error near i, docID stating "
C#
only assignment call increment decrement await and new object expressions can be used as a statement". Any help would be appreciated. Please help me to display it.

What I have tried:

I tried tweaking the code but i am getting the syntax error.
Posted
Updated 24-Aug-16 21:49pm
Comments
Patrice T 25-Aug-16 3:33am    
Show where is the error in code.
Member 8010354 25-Aug-16 3:42am    
I am getting error at this line.
EmailAddress += employee.ArtifactID + favouriteDocumentsField.Name + "Object: " + index, docID);

Exactly at: index, docID);
Patrice T 25-Aug-16 3:47am    
Use Improve question to update your question.

Look at your code:
C#
EmailAddress += employee.ArtifactID + favouriteDocumentsField.Name + "Object: " + index, docID);

What is the end of that doing?
If I cut it down a bit it'll be clearer:
C#
EmailAddress += "a string", docID);
What do you expect the compiler to do with the command and the stuff to it's right?
Probably, what you meant was:
C#
EmailAddress += employee.ArtifactID + favouriteDocumentsField.Name + "Object: " + index + docID;
But you need to think about what you are doign as that won't work either, given that the line is inside a loop and will concatenate all the "email addresses" together:
joe@gmail.commike@gmail.com@sara@mydomain.co.in
 
Share this answer
 
Comments
Member 8010354 25-Aug-16 5:02am    
Yeah for that i am going to add + ";"; so it will separate but i foubd that the code is not able to move forward near LIST<int32> multiobject = ((List<int32>)favouritefieldname.value);
Try this
C#
EmailAddress += employee.ArtifactID + favouriteDocumentsField.Name + "Object: " + index, docID;

(remove the ) at the end.
[Update]
May be replacing the , by a + can help too
 
Share this answer
 
v2
Comments
Member 8010354 25-Aug-16 4:34am    
No it is not working.

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