
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
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;
- Related Articles
- What is a type cast in C/C++?
- What is a Ternary operator/conditional operator in C#?
- What is sizeof operator in C++?
- What is Comma operator in C++?
- What is dot operator in C++?
- What is arrow operator in C++?
- What is pointer operator & in C++?
- What is Pointer operator * in C++?
- What is the ?-->? operator in C++?
- What is ternary operator in C#?
- What is double address operator(&&) in C++?
- What is the operator precedence in C#?
- What is an assignment operator in C#?
- What is an arrow operator, `->` in C++?
- Const cast in C++

Advertisements