devxlogo

C#

Use the Namespace Alias for Better Readability

For better readability, C# provides a way to shorten the namespaces with an alias. Please see below for an example: using ExcelInterop = Microsoft.Office.Interop.Excel;var excelInteropApplication = new ExcelInterop.Application();

Check Whether an Input Argument Is Null in C#

Use this extension method in C# to check whether or not an input argument is null, and throw an error if necessary. Extension method: public static void CheckIfParameterIsValid(this T o,

Extension Method to Update All Items in a List

See how to use an extension method in C# to update all items in a list. public static IEnumerable ForEach(this IEnumerable collection, Action action){//Loop thru the collectionforeach (T item in