Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Default operator in C#
Using the default, you can get the default value of every reference and value type. The expressions set as default are evaluated at compile-time.
To get the default for int −
default(int);
To get the default for long −
default(long)
Let us see the code to display default values −
Example
using System;
public class Demo {
public static void Main() {
int val1 = default(int);
long val2 = default(long);
bool val3 = default(bool);
// default for int
Console.WriteLine(val1);
// default for long
Console.WriteLine(val2);
// default for bol
Console.WriteLine(val3);
}
}
Output
0 0 False
Advertisements
