Maximum/Minimum value for generic types

In playing with generics, I haven’t been able to find out how to get the maximum value and minimum value of a generic type (whether through adding an interface restriction on the type or otherwise). I know you can get the default value by using default(T), but it would be nice to have a method that gets the maximum and minimum value (for types like Integer, DateTime, …).
 
 
If you know, please post it in a comment. If I find out, I’ll post a follow-up posting.
 
 
Advertisements

One thought on “Maximum/Minimum value for generic types

  1. Can you do lst.Sort() then just take the first and last item?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s