Extension method must be defined in non-generic static class

.net, c#, compiler-errors, extension-methods

Solution

If you remove "this" from your parameters it should work.

public static IChromosome To<T>(this string text)

should be:

public static IChromosome To<T>(string text)

Problem

Error at: ``` public partial class Form2 : Form ``` Probable cause: ``` public static IChromosome To<T>(this string text) { return (IChromosome)Convert.ChangeType(text, typeof(T)); } ``` Attempted (without static keyword): ``` public IChromosome To<T>(this string text) { return (IChromosome)Convert.ChangeType(text, typeof(T)); } ```

Original source