# For loop C#?

**URL:** https://discussions.unity.com/t/for-loop-c/66752
**Category:** Questions & Answers
**Created:** [March 24, 2013, 10:21am UTC](https://discussions.unity.com/t/for-loop-c/66752 "2013-03-24T10:21:10Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![AndreasX12](https://avatars.discourse-cdn.com/v4/letter/a/a6a055/32.png) [@AndreasX12](https://discussions.unity.com/u/AndreasX12)
#### Post date: [March 24, 2013, 10:21am UTC](https://discussions.unity.com/t/for-loop-c/66752/1 "2013-03-24T10:21:10Z")

</div>

Hello, I can’t get my for loop working, this is the code:

```
public int test = 1;	
	
IEnumerator RotateWheelLeft() {
	for (test i = 0; i = 50; i++) {
			// stuff
		}
			
	}

```

The error is: `CarScript.test' is a `field’ but a `type’ was expected

Thanks, Andreas

---

<div class="post-metadata">

### Author: ![Khada](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/khada/32/278735_2.png) [@Khada](https://discussions.unity.com/u/Khada)
#### Post date: [March 24, 2013, 10:27am UTC](https://discussions.unity.com/t/for-loop-c/66752/2 "2013-03-24T10:27:07Z")

</div>

test i = 0; //only makes sense if ‘test’ is a type that can be set to 0  
int i = 0; //an int is a type that can be set to 0 and used as a loop counter

All variable declarations use the following structure:

```
//type name = value
  int num = 0;

```

---

<div class="post-metadata">

### Author: ![chrisspinu](https://avatars.discourse-cdn.com/v4/letter/c/8e7dd6/32.png) [@chrisspinu](https://discussions.unity.com/u/chrisspinu)
#### Post date: [March 21, 2020, 4:38pm UTC](https://discussions.unity.com/t/for-loop-c/66752/3 "2020-03-21T16:38:33Z")

</div>

for (int i = 0; i == 50; i++) {  
// stuff  
}  
// You need to add two equals
