Can i use a generic implicit or explicit operator? C#
Posted
by acidzombie24
on Stack Overflow
See other posts from Stack Overflow
or by acidzombie24
Published on 2010-05-31T05:25:53Z
Indexed on
2010/05/31
5:32 UTC
Read the original article
Hit count: 196
How do i change the following statement so it accepts any type instead of long? Now here is the catch, if there is no constructor i dont want it compiling. So if theres a constructor for string, long and double but no bool how do i have this one line work for all of these support types?
ATM i just copied pasted it but i wouldnt like doing that if i had 20types (as trivial as the task may be)
public static explicit operator MyClass(long v) { return new MyClass(v); }
© Stack Overflow or respective owner