AddComponent (collider2D) give abstract error ?

I try to add Collider2D to a gameobject following the example in the Appi.

But i have this error :

Cannot add component of type ‘Collider2D’ because it is abstract.
Add component of type that is derived from ‘Collider2D’ instead.

What must i do to make it work ? Thanks for any answer !)

(Here’s my try :slight_smile:

gameObject.AddComponent(Collider2D);

/// Or also :

var newcolls = ImportFrom.GetComponents(Collider2D);	
		
for (var ki=0;ki<newcolls.Length;ki++ )         
{		
var nn : Collider2D = newcolls[ki];	
nn = gameObject.AddComponent(Collider2D);
}

Are you using Unity5?
if so check this:

Try using Generic:

gameObject.AddComponent<Collider2D>();