This content is part of a third party extension that is not supported by the Cake project.
For more information about this extension see Cake.Incubator.
Summary
Throws a
System.ArgumentNullException
if a string is null or empty, otherwise returns the value
- Assembly
- Cake
.Incubator .dll - Namespace
- Cake
.Incubator .AssertExtensions - Containing Type
- AssertExtensions
Syntax
public static string ThrowIfNullOrEmpty(this string value, string varName)
Examples
replace the following
string myArg = "";
if (string.IsNullOrEmpty(myArg))
{
throw new ArgumentNullException(nameof(myArg));
}
var arg1 = myArg;
with
string myArg = "";
var arg1 = myArg.ThrowIfNullOrEmpty(nameof(myArg));
Attributes
Type | Description |
---|---|
Cake |
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 |