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
What is Cast Operator () in C#?
Type conversion is converting one type of data to another type. Explicit conversions are done explicitly by users using the pre-defined functions and require a cast operator.
Let us see an example to cast double to int −
Example
using System;
namespace Demo {
class Program {
static void Main(string[] args) {
double a = 4563.56;
int x;
x = (int)a;
Console.WriteLine(x);
Console.ReadKey();
}
}
}
To cast double to int, we perfomed explicit type casting −
x = (int)a;
Advertisements
