---
title: "Nullable Types in C#"  
description: "In this blog, I’m explaining about nullable types  in  C#  Defining a nullable typeis very similar to defining the equivalent non-nullable type. The d"  
author: "priyanka kushwaha"  
published: 2015-03-03  
updated: 2018-02-22  
canonical: https://www.mindstick.com/blog/823/nullable-types-in-c-sharp  
category: ".net"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Nullable Types in C#

In this [blog](https://www.mindstick.com/articles/12705/myths-and-misconception-about-blog), I’m explaining about [nullable](https://www.mindstick.com/interview/23385/why-to-use-nullable-coalescing-operator-in-c-sharp) types in C#\

Defining a nullable type is very similar to defining the equivalent non-nullable type. The [difference](https://www.mindstick.com/articles/157114/good-news-or-bad-news-and-the-difference-is) is in the use of the? type modifier.

[int](https://www.mindstick.com/forum/159137/how-to-convert-date-int-to-date-in-sql)? is a nullable [value](https://www.mindstick.com/articles/23219/an-optimized-description-adds-value-to-experience-and-in-turn-effectively-guest-posting-packages) type.

? : lift [operator](https://www.mindstick.com/blog/144/union-intersection-and-except-operator-in-sql-server)

##### \

##### Example:

##

```
int? x =null;int y = 3;int? result = x ?? 0;//This operator assigned the value of 'x' to result if "x" is null else it will assign the value of "y" to "result"//So if first  variable is null then will be assigned else the value of second variable will  be assigned.Console.WriteLine(result.ToString());Output:0
```

##### \

##### Example:

```
int? x =null;int y = 3;int? result = x ?? y;Console.WriteLine(result.ToString());Output:3
```

##### \

##### Example:

##

```
int? x =4;int y = 3;int? result = x ?? y;Console.WriteLine(result.ToString());Output:4
```

---

Original Source: https://www.mindstick.com/blog/823/nullable-types-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
