Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# nullable generic

static void Main(string[] args)
{
    int? i = GetValueOrNull<int>(null, string.Empty);
}


public static Nullable<T> GetValueOrNull<T>(DbDataRecord reader, string columnName) where T : struct
{
    object columnValue = reader[columnName];

    if (!(columnValue is DBNull))
        return (T)columnValue;

    return null;
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: if list does not contain then add c# 
Csharp :: regex for accepting a file name c# 
Csharp :: c# chunk array 
Csharp :: switch statement c# example 
Csharp :: visual studio c# mark class deprecated 
Csharp :: rotate along normal unity 
Csharp :: c# wpf row definition height * in code 
Csharp :: linq datatable 
Csharp :: reload usercontol wpf 
Csharp :: set the page that FormsAuthentication.RedirectFromLoginPage redirects to 
Csharp :: c# sftp 
Csharp :: unity camera fade to black 
Csharp :: longest substring without repeating characters c# 
Csharp :: how to redirect to another page in button clicked in asp.net c# index.cshtml 
Csharp :: winforms input box 
Csharp :: C# program lambda Func 
Csharp :: freeze scene unity 
Csharp :: c# map function 
Csharp :: how to get the today date in c# 
Csharp :: read all lines split C# 
Csharp :: c# console delete last character 
Csharp :: go right unity 
Csharp :: unity rotate around point 
Csharp :: C# scrape html document 
Csharp :: link form to a button in dashbord visual c# 
Csharp :: unity line renderer opacity 
Csharp :: Advertisement code for unity 
Csharp :: rename join table ef core 
Csharp :: Get location in Xamarin - NAYCode.com 
Csharp :: httpclient getstringasync 
ADD CONTENT
Topic
Content
Source link
Name
6+4 =