AssertExtensions.

ThrowIfNullOrWhiteSpace(string, string) Method

Summary

Throws a System.ArgumentNullException if a string is null or white space, otherwise returns the value

Syntax

public static string ThrowIfNullOrWhiteSpace(this string value, string varName)

Examples

replace the following
string myArg = "";
if (string.IsNullOrWhiteSpace(myArg)) 
{
  throw new ArgumentNullException(nameof(myArg));
}
var arg1 = myArg;
with
string myArg = "";
var arg1 = myArg.ThrowIfNullOrWhiteSpace(nameof(myArg));

Attributes

Type Description
CakeAliasCategoryAttribute

Parameters

Name Type Description
value string The object to check
varName string The name of the variable

Return Value

Type Description
string The non-null value