Nullable extension: Has Value And Equals

image_pdfimage_print
   
 
//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 &amp;&amp; source.Value.Equals(target);
        }

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

    }
}

   
     


This entry was posted in Data Types. Bookmark the permalink.