Click here to Skip to main content
13,094,732 members (96,885 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

3.4K views
Posted 2 Jun 2011

Handy Extension Methods

, 2 Jun 2011
Rate this:
Please Sign up or sign in to vote.
I'm a fan of these guys... (Though I feel like I might catch some flack for the first one.)public static bool IsNullOrEmpty(this ICollection collection){ return collection == null || collection.Count == 0;}public static float Clamp(this float value, float low, float hi){...

I'm a fan of these guys... (Though I feel like I might catch some flack for the first one.)


public static bool IsNullOrEmpty<T>(this ICollection<T> collection)
{
    return collection == null || collection.Count == 0;
}
 
public static float Clamp(this float value, float low, float hi)
{
    System.Diagnostics.Debug.Assert(low < hi);
    value = (value < low) ? low : value;
    return (value > hi) ? hi : value;
}

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

IGood
Software Developer 5TH Cell
United States United States
Tools & gameplay programmer at 5TH Cell Media.
DigiPen student class of '09.

You may also be interested in...

Pro

Comments and Discussions

 
GeneralClamp is cool... Here is the generics alternate: pub... Pin
Aiscrim8-Jun-11 0:51
memberAiscrim8-Jun-11 0:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170813.1 | Last Updated 2 Jun 2011
Article Copyright 2011 by IGood
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid