Resolving null values in C#

Say you have a method which accepts a string parameter. The method may need to handle null values in some way. One strategy is to validate the parameter and throw an exception:

private static string Resolve(string input)
{
	if (input == null) throw new ArgumentNullException("Input");
.
.
.
}

Another strategy is to provide some default value with an if-else statement:

Read more of this post

Advertisement

Resolving null values in C#

Say you have a method which accepts a string parameter. The method may need to handle null values in some way. One strategy is to validate the parameter and throw an exception:

private static string Resolve(string input)
{
	if (input == null) throw new ArgumentNullException("Input");
.
.
.
}

Another strategy is to provide some default value with an if-else statement:

Read more of this post

A new way of checking for nulls in C# 6

In this post we explored a couple of ways to handle null values in C# 5.

Obviously you can just test whether an object is equal to null:

private static string Resolve(string input)
{
	if (input == null) throw new ArgumentNullException("Input");
.
.
.
}

Read more of this post

Resolving null values in C#

Say you have a method which accepts a string parameter. The method may need to handle null values in some way. One strategy is to validate the parameter and throw an exception:

private static string Resolve(string input)
{
	if (input == null) throw new ArgumentNullException("Input");
.
.
.
}

Another strategy is to provide some default value with an if-else statement:

Read more of this post

Resolving null values in C#

Say you have a method which accepts a string parameter. The method may need to handle null values in some way. One strategy is to validate the parameter and throw an exception:

private static string Resolve(string input)
{
	if (input == null) throw new ArgumentNullException("Input");
.
.
.
}

Another strategy is to provide some default value with an if-else statement:

Read more of this post

Elliot Balynn's Blog

A directory of wonderful thoughts

Software Engineering

Web development

Disparate Opinions

Various tidbits

chsakell's Blog

WEB APPLICATION DEVELOPMENT TUTORIALS WITH OPEN-SOURCE PROJECTS

Once Upon a Camayoc

Bite-size insight on Cyber Security for the not too technical.

%d bloggers like this: