Part 2: Data Types and Variables

Previous Part
Part 1: Introduction to C# Programming

Data Types:

Data Types in C# refer to the type of data that can be stored in a variable. C# provides a variety of built-in Data Types, including:

1. Numeric Data Types:

     i) Integral Types: sbyte, byte, short, ushort, int, uint, long, ulong (Used to store integers (whole numbers))

     ii) Floating-Point Types: float, double, decimal (Used to store floating-point numbers (decimal numbers) etc.)

     iii) Character Data Type: char (Used to store single characters)

2. Boolean Data Type: bool (Used to store true/false values)

3. Object Data Type: object (Used to store any data types)

4.String Data Type: string (Used to store a sequence of characters)

5.dynamic: Represents a type that is resolved at runtime

Variables:

Variables in C# are used to store data values of a specific Data Type. A variable has a name, a Data Type, and a value. Variables must be declared before they can be used, and they can be assigned values using the assignment operator (=).


Here's an example of declaring and initializing a variable in C#:


int myInt = 42;
bool myBool = true;
double myDouble = 3.14;
string myString = "Hello, world!";



Next Part:

Part 3: Control Statements

No comments:

Post a Comment