Nullable extension: Has Value And Equals : Nulllable « Data Types « C# / C Sharp






Nullable extension: Has Value And Equals

 
//http://arolibraries.codeplex.com/
//The MIT License (MIT)


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AroLibraries.ExtensionMethods
{
    public static class NullableExt
    {

        public static bool Ext_HasValueAndEquals<T>(this Nullable<T> source, T target) where T : struct
        {
            return source.HasValue && source.Value.Equals(target);
        }

        public static bool Ext_HasValueAndEquals<T>(this Nullable<T> source, Nullable<T> target) where T : struct
        {
            return source.HasValue && source.Value.Equals(target);
        }

    }
}

   
  








Related examples in the same category

1.Declare a nullable type by adding the ? type modifier in a value type declaration.
2.Nullable variable
3.Nullable bool Types
4.Nullable int Types
5.Nulllable HasValue
6.Is it Nullable