Original Post
Hey guys, Looking at the extension feature from Nick Gravelyn's site, I cannot compile the code he uses as a test example: This example will compile however:
Quote:Has the extension feature been altered to only allow for static classes? Nick's test class: (yelds error as allready quoted)
Extension methods must be defined in a non-generic static class
public class Sprite
{
public Texture2D Texture { get; set; }
public Vector2 Position { get; set; }
public Color Color { get; set; }
public static void Draw(this SpriteBatch spriteBatch, Sprite sprite)
{
spriteBatch.Draw(sprite.Texture, sprite.Position, sprite.Color);
}
}
public static class SpriteManager
{
public static void DrawSprite(this SpriteBatch spritebatch, Sprite sprite)
{
spritebatch.Draw(sprite.Texture, sprite.Position, sprite.Color);
}
}