public static class ExtensionMethods { public static void CheckNotNull(this T obj, string paramName) where T : class { if (obj == null) throw new ArgumentNullException(paramName); } }
public void MyMethod(string str) { str.CheckNotNull(nameof(str)); // If str is null, this line will throw an ArgumentNullException }In this example, we call the CheckNotNull method on a string parameter called str. We pass the name of the parameter using the nameof operator so that we can include it in the exception message if the parameter is null. Again, without more information about the required package/library, it is impossible to determine where this CheckNotNull method is coming from.