All C# extension methods for type nullable-t
Calling Value.ToString on a System.Nullable<T> type where the value is null will result in an "Nullable object must have a value." exception being thrown. This extension method can be used in place of .ToString to prevent this exception from occurring.
Returns a the value of a Nullable type if it has a value or it will return a default value
int? index = GetIndex();
if (index.HasValue && index.Value == 10) ...
ExtensionMethod.NET was built by
Loek van den Ouweland and Fons Sonnemans
By using this website, you agree to the legal stuff.
We thank all who contributed to this website for the last twelve years. It really helped making this website a success!
Just looking for examples? Visit our sister site
Looking for Visual Studio Code Snippets? Visit our sister site VisualStudioCodeSnippets.com.