Re: generics - constraint



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!

--

----------------------------------------------

http://michael.moreno.free.fr/


.



Relevant Pages

  • Re: generics - constraint
    ... checks typeofand throws an exception if it isn't int, float, or ... Generics are very limited then because you cannot perform any ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Strange java behaviour
    ... It throws exception on line 4 but not on line 3. ... result as an int, ... Line 3 is a float division by zero, and there is a value, ... positive float by a zero float. ...
    (comp.lang.java.programmer)
  • Re: Strange java behaviour
    ... It throws exception on line 4 but not on line 3. ... result as an int, ... Line 3 is a float division by zero, and there is a value, ... positive float by a zero float. ...
    (comp.lang.java.programmer)
  • Re: Abnormal program termination
    ... foo.c:4: warning: function declaration isn't a prototype ... Your version is legal under C90 rules, but int mainis more explicit ... float ave(), average; ...
    (comp.lang.c)
  • RTF Render with Scale
    ... float fHorzSizeInches = nHorzSize / 25.4f; ... IntPtr hdc = graphics.GetHdc; ... int nHorzSize = SafeNativeMethods.GetDeviceCaps(hdc, ... PHYSICALWIDTH = 110, ...
    (microsoft.public.dotnet.languages.csharp)