Re: generics - constraint
- From: Jon Skeet [C# MVP] <skeet@xxxxxxxxx>
- Date: Sun, 14 Jan 2007 07:45:02 -0000
Michael Moreno <abc@xxxxxxx> wrote:
No, I think the best you can do is write a static constructor that
checks typeof(T) and throws an exception if it isn't int, float, or
double.
Thanks. Generics are very limited then because you cannot perform any
operator >, <, +, -, *, / in the code.
I hope they will fix that!
There are workarounds already. Have a look at
http://www.codeproject.com/csharp/genericnumerics.asp
for more information.
--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
.
- References:
- generics - constraint
- From: Michael Moreno
- Re: generics - constraint
- From: Jesse McGrew
- Re: generics - constraint
- From: Michael Moreno
- generics - constraint
- Prev by Date: Re: Boxing and Unboxing ??
- Next by Date: Re: Service Wont Start Programatically (ACCESS DENIED)
- Previous by thread: Re: generics - constraint
- Next by thread: Re: Searching text in datagridview
- Index(es):
Relevant Pages
|