Ternary If Statement in C#

Sometimes you just need a ternary statement, i.e. you don't want to return a value from the condition ? true : false construct. Here is an extension method to help you out (the usage example isn't the best).
    class Program
    {
        static void Main(string[] args)
        {
            List<string> test = new List<string>();
            ArrayList source = new ArrayList();

            source.Add(1);
            source.Add("hello");

            source.Each<object>(x => 
                (x is String).IfElse
                    (
                        () => test.Add((string)x),
                        () => test.Add(x.ToString())
                    ));
        }
    }

    static class Extensions
    {
        public static void If(this bool @this, Action isTrue)
        {
            if (@this)
                isTrue();
        }

        public static void IfElse(this bool @this, Action isTrue, Action isFalse)
        {
            if (@this)
                isTrue();
            else
                isFalse();
        }

        internal static void Each<T>(this IEnumerable<T> @this, Action<T> action)
        {
            foreach (T t in @this)
                action(t);
        }

        internal static void Each<T>(this IEnumerable @this, Action<T> action)
        {
            foreach (object t in @this)
                if (t is T)
                {
                    action((T)t);
                }
        }
    }

Ruby-like each statement in C#

Funny this isn't in the provided Enumerable extension methods.

In any case, here it is:

        internal static void Each<T>(this IEnumerable<T> @this, Action<T> action)
        {
            foreach(T t in @this)
                action(t);
        }

        internal static void Each<T>(this IEnumerable @this, Action<T> action)
        {
            foreach (object t in @this)
                if (t is T)
                {
                    action((T)t);
                }
        }

An example:

   objects.Each(x => DoSomethingFunky(x, "some parameter"));

Using Is.Gd/Bitly/TinyUrl/Facebook Post in Chrome

Put your favorite bookmarklet at your fingertips.
«December»
SunMonTueWedThuFriSat
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910