I have a fun开发者_StackOverflowction defined like this:
public static bool ComposeObjects(List<ObjectID> TheListOfIDs)
The definition of ObjectID
looks like this:
public class ObjectID
{
int ObjectID { get; set; }
byte Var1 { get; set; }
}
This function ComposeObjects
receives a collection of ObjectID
s and I want to loop in this collection.
How do you write the for each statement?
So far I have
foreach (ObjectID in TheListOfIDs)
{
// ...
}
Thanks for your suggestion.
You need to give a variable name:
foreach (ObjectID id in TheListOfIDs)
{
// Just for example...
int x = id.ObjectID;
byte b = id.Var1;
}
Your having a syntax problem? What errors? What have you tried?
foreach (var oID in TheListOfIDs)
{
...
}
精彩评论