static void Main(string[] args) > { > Test test = "Hello World"; > } > > public class Test > { > public static implicit operator Test(string s) > { > return s; // obviously wrong but compiles and is re-entrant when run > } > }I think the problem is that the operator does not return an instance of Test
public class Test { public string Value { get; private set; } public Test(string s) { this.Value = s; } public static implicit operator Test(string s) { return new Test(s); // obviously wrong but compiles and is re-entrant when run } }