Error : Extension method must be defined in a non-generic static class

You put extension methods in their own special static class.

public static class ExtensionMethods {
  Public Static Vector2 RotateThisVector(this Vector2 v, float angle) {
    //...
  }
}

Or you could group them by type, if you have many extension methods based on type and you want to keep them very organised, you could have a folder called ExtensionMethods, and you could have a class for each type

public static class Vector2_ExtensionMethods {
  Public Static Vector2 RotateThisVector(this Vector2 v, float angle){
    //...
  }
  //Other vector2 extension methods
}

Please also see this post about code tags, for posting code on the forum.

2 Likes