- Home /
Question by
Loki18000 · May 25, 2015 at 12:08 PM ·
lengthdefinition
Foreach Length not defined C#
Hello guys, I am having some issues with a Foreach loop and .Length in C#
void Update() {
foreach (GameObject gameObj in GameObject.FindGameObjectsWithTag("kills")) {
print (gameObj.Length);
}
}
it comes up with the error "Does not contain a definition for 'Length'"
I have tried a few other ways for getting the number of "kills" but .Length will not work.
Thanks for any help guys
Comment
Best Answer
Answer by DoTA_KAMIKADzE · May 25, 2015 at 12:09 PM
If I understood you correctly - you want something like that?:
GameObject[] goS = GameObject.FindGameObjectsWithTag("kills");
print(goS.Length);
Your answer
Follow this Question
Related Questions
How do I cut off a section of my terrain? 2 Answers
array out of range while updating mesh variables 4 Answers
Bytes array always empty in WWW object (on WebPlayer) 0 Answers
Instantiating objects randomly based on the length of an object 0 Answers
one class (File) with different definitions in different projects 1 Answer