Home >Backend Development >C#.Net Tutorial >What is the cast operator () in C#?
Type conversion is to convert one type of data into another type of data. Explicit conversion is done explicitly by the user using predefined functions and requires a cast operator.
Let us see an example of casting double to int -
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 convert double to int, we perform an explicit type conversion-
x = (int)a;
The above is the detailed content of What is the cast operator () in C#?. For more information, please follow other related articles on the PHP Chinese website!