# Java to C# syntax problem \* Solved

**URL:** https://discussions.unity.com/t/java-to-c-syntax-problem-solved/419863
**Category:** C# & .NET
**Tags:** Scripting
**Created:** [August 5, 2010, 8:10pm UTC](https://discussions.unity.com/t/java-to-c-syntax-problem-solved/419863 "2010-08-05T20:10:46Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![solid\_1](https://avatars.discourse-cdn.com/v4/letter/s/77aa72/32.png) [@solid\_1](https://discussions.unity.com/u/solid_1)
#### Post date: [August 5, 2010, 8:10pm UTC](https://discussions.unity.com/t/java-to-c-syntax-problem-solved/419863/1 "2010-08-05T20:10:46Z")

</div>

Hey! i need to “translate” a for loop from java to C#.  
but i can’t manage to convert it to C# syntax.

i’ve looked at this C# example:

```auto
foreach (ItemType item in someList)
{
    item.DoSomething();
}

```

but i can’t translate this one:

```auto
for (var state : AnimationState in animation) {
			state.speed = 1.5;
			}

```

do i have to pre-define variables for that? or something.  
thanks.

---

<div class="post-metadata">

### Author: ![Chris-Sinclair](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/chris-sinclair/32/241371_2.png) [@Chris-Sinclair](https://discussions.unity.com/u/Chris-Sinclair)
#### Post date: [August 5, 2010, 8:34pm UTC](https://discussions.unity.com/t/java-to-c-syntax-problem-solved/419863/2 "2010-08-05T20:34:12Z")

</div>

This doesn’t work? If so, what’s the compile error?

```auto
foreach(AnimationState state in animation)
{
	state.speed = 1.5;
}

```

EDIT: what type is animation? Does it have a collection of “AnimationState” objects?

---

<div class="post-metadata">

### Author: ![solid\_1](https://avatars.discourse-cdn.com/v4/letter/s/77aa72/32.png) [@solid\_1](https://discussions.unity.com/u/solid_1)
#### Post date: [August 5, 2010, 8:37pm UTC](https://discussions.unity.com/t/java-to-c-syntax-problem-solved/419863/3 "2010-08-05T20:37:05Z")

</div>

i missed a couple of things there.  
ye it had a animation state collection. but what i was missing was a part of the syntax in the translation.

a little stupid, hehe.

```auto
foreach(AnimationState state in animation)
{
   state.speed = 1.5f;
}

```

worked. thanks!
