Home Python C Language C ++ HTML 5 CSS Javascript Java Kotlin SQL DJango Bootstrap React.js R C# PHP ASP.Net Numpy Dart Pandas Digital Marketing

C# Data Types


Sure! In C#, data types define the type of data that a variable can hold. Here's a simple explanation of some common data types in C# with examples:

  1. Integer Types:

    • int: Represents whole numbers (integers) ranging from -2,147,483,648 to 2,147,483,647.

Example

int age = 25;

Example

long population = 77952904;

2. Floating-Point Types:

Example

float pi = 3.14f;

Example

double height = 6.2;

3. Decimal Type:

Example

decimal price = 10.99m;

4. Boolean Type:

Example

bool isSunny = true;

5. Character Type:

Example

char grade = 'A';

6. String Type:

Example

string message = "Hello, world!";

7. Enum Type:

Example

enum Day { Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday }; Day today = Day.Wednesday;

8. Object Type:

Example

object data = 10;

These are some of the common data types in C#. Understanding data types is important because it helps you declare variables with appropriate types and perform operations accordingly.



Advertisement





Q3 Schools : India


Online Complier

HTML 5

Python

java

C++

C

JavaScript

Website Development

HTML

CSS

JavaScript

Python

SQL

Campus Learning

C

C#

java