KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Given the following struct: public struct Foo<T> { public Foo(T obj) { } public static implicit operator Foo<T>(T input) { return new Foo<T>(input); } } This code compiles: private Foo<ICloneable> MakeFoo() { string c = "hello"; return c; // Success: string is ICloneable, ICloneable implicitly converted to Foo<ICloneable> } But this code doesn't compile -- why? private Foo<ICloneable> MakeFoo() { ICloneable c = "hello"; return c; // Error: ICloneable can't be converted to Foo<ICloneable>. WTH? }
Tags (comma-separated)
Save Edits
Cancel