how do I use coroutine without IEnumerator,How do I use StartCoroutine without IEnumerator

when i try to use croroutine with IEnumerator it always returns a error and i cant figure out why this is the code ive been working on.

   void OnCollisionEnter2D (Collision2D collisionInfo) {

	if (collisionInfo.collider.tag == "Damaging") {
		health = health - 1;
	}
	if (collisionInfo.gameObject.name.Equals ("Spike")) {
		StartCoroutine(IFrames());
	}
	
}
public IEnumerator IFrames() {
		Physics2D.IgnoreLayerCollision (10, 6, true);
		new WaitForSeconds (5f);
		Physics2D.IgnoreLayerCollision (10, 6, false);
},when i try to use Coroutine everything says i need IEnumerator but it always brings back a error when i cant find what i did wrong. Here is the code im working on. 	

 void OnCollisionEnter2D (Collision2D collisionInfo) {

	if (collisionInfo.collider.tag == "Damaging") {
		health = health - 1;
	}
	if (collisionInfo.gameObject.name.Equals ("Spike")) {
		StartCoroutine(IFrames());
	}
	
}
public IEnumerator IFrames() {
		Physics2D.IgnoreLayerCollision (10, 6, true);
		new WaitForSeconds (5f);
		Physics2D.IgnoreLayerCollision (10, 6, false);
}

Look at this line:

new WaitForSeconds (5f);

It should be:

yield return new WaitForSeconds (5f);

IEnumerator is an interface that can be used to declare generator / iterator methods in C# which are the foundation of Unity’s coroutine concept. Iterator methods require to contain at least one yield statement. Otherwise the compiler can not turn your method into a statemachine. The point of a coroutine is that you can wait inside the coroutine with the yield statement.

As yummy81 already explained, you’re missing the yield return infront of your WaitForSeconds object. If you have issues understanding coroutines or want to get a better understanding how they work under the hood, have a look at my coroutine crash course.