A set of handy C# extension methods for objects, collections, strings, and streams to make your code cleaner and more expressive.
bool IsNull(this object obj)
✅ Returnstrueif the object isnull.bool IsNotNull(this object obj)
✅ Returnstrueif the object is not null.
void ForAll(this IEnumerable<T> source, Action<T> action)
Executesactionfor each element. Safe ifnull.void Times(this int count, Action<int> action)
Executesactioncounttimes. Safe ifnull.bool IsEmpty(this IEnumerable value)– Checks if emptybool IsNotEmpty(this IEnumerable value)– Checks if not emptybool IsNullOrEmpty(this IEnumerable value)– Checks null or emptybool IsNotNullOrEmpty(this IEnumerable value)– Checks not null and not emptyT Pop<T>(this IList<T> source)– Returns last element and removes itT Shift<T>(this IList<T> source)– Returns first element and removes itvoid Unshift<T>(this IList<T> source, T toAdd)– Adds element at first positionT AnyOne<T>(this IEnumerable<T> source)– Returns any element (throws if null/empty)bool None<T>(this IEnumerable<T> source, Func<T, bool> predicate = null)– Checks if no elements match the predicate
void EqualJsonCheck(this object obj, object toCompare)
Compares objects via JSON serialization and throws if unequal.bool IsEqualJson(this object obj, object toCompare)
Returnstrueif objects are equal via JSON.
string ExpEnv(this string text)– Shortcut forEnvironment.ExpandEnvironmentVariablesstring UseFormat(this string text, params string[] @params)– Usesstring.Formatfor placeholders
byte[] ToByteArray(this Stream stream)– Converts a Stream to a byte arrayStream ToStream(this byte[] byteArray)– Converts a byte array to a Stream