Re: How to use generics?



Martin <martingagne@xxxxxxxxx> wrote:
In the following example, I'd like to replace int by a generic. In
order word, I would like to replace int by float, double, byte or
something like that. I've tried to find a common interface or
something like that, but I didn't find.

There isn't one, I'm afraid. This is the kind of thing that generics
just don't work for in their current form :(

--
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
.



Relevant Pages

  • How to use generics?
    ... I'd like to replace int by a generic. ... order word, I would like to replace int by float, double, byte or ... maxSoFar = Math.Max; ...
    (microsoft.public.dotnet.languages.csharp)
  • 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)
  • Re: RAD vs. performance
    ... work with both int and float. ... name (e.g. "+" for both int and float addition). ... Again, it's a compatibility issue. ... contend that assuming interfaces are equivalent and inferring the most ...
    (comp.lang.misc)
  • (part1b) Han from China teaches you C
    ... int flist, mlist, slist; ... float board_size; ... static void draw_tube(float bottom_radius, float top_radius, ... glVertex3f(xmin, ymin, zmax); glVertex3f; ...
    (comp.lang.c)

Loading