MinMaxArray

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi,
I would like to have a generic class MinMaxArray<T>, which is a
wrapper around an array of T[] and computes minimum, maximum, and
average value from the array T[]. I need it only for the basic numeric
types (int, float, etc.).

I had problems with operators < > + and /, when I was computing
minimum, maximum and average values. I have errors like "Operator ...
cannot be applied to operans of type 'T' and 'T'." So, I use
IComparer<T> instead of operators < >, but I do not know, how to
compute average value (sum and divide) for a generic numeric type T.
Is there any easy way to do it? Disable the type checking in the
compile time?

Thx
.



Relevant Pages

  • Re: Can anyone help me on C++ question. tq
    ... >> Array manipulations, Class, Exception handling, Generic class. ... >A set is a list without repetition, ... >Intersection uses only common elements, might be thought of as *. ...
    (comp.programming)
  • sizeof(T) for C# 2.0 generic classes
    ... for a type parameter T in generic class cls. ... I need some generic way to covert ... T array to an array of bytes and conversely, ...
    (microsoft.public.dotnet.csharp.general)
  • sizeof(T) for C# 2.0 generic classes
    ... for a type parameter T in generic class cls. ... I need some generic way to covert ... T array to an array of bytes and conversely, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Create button control at runtime
    ... but there is a way to create using an array? ... dim btnArray as new ArrayList'estimate the capacity you'll need. ... But if the total number of buttons are unknown until they are all created, then using an ArrayList or List would be the way to go (I'm unfamiliar with the Listgeneric class, so you may also want to look into this as it may be just as efficient as using a normal array, but I'm not sure)... ...
    (microsoft.public.dotnet.languages.vb)