1. Introduction to C#
History of C#: C# was developed by Microsoft in the early 2000s as part of its .NET initiative. It is
designed for building a variety of applications including web, mobile, desktop, and games.
Characteristics of C#: It is a modern, object-oriented programming language. It supports features
like garbage collection, type safety, and automatic memory management.
Structure of a C# Program: A typical C# program consists of classes, methods, and namespaces,
with the Main() method being the entry point.
2. Data Types and Variables in C#
Basic Data Types: Common data types include int (integer), float (floating-point), char (character),
double (double precision floating-point), and bool (boolean).
Constants and Literals: Constants are fixed values that do not change during program execution,
while literals are the direct representation of values like numbers or characters.
Variable Declaration: Variables must be declared before they are used, specifying the type and
name of the variable.
3. Operators in C#
Arithmetic Operators: Includes +, -, *, /, % for performing basic arithmetic.
Relational Operators: Used to compare values, such as ==, !=, >, <.
Logical Operators: Logical operations include && (AND), || (OR), ! (NOT).
Bitwise Operators: Operators like &, |, ^, <<, and >> are used to manipulate data at the bit level.
Assignment and Miscellaneous Operators: Assignment uses = to assign values, and other operators
include sizeof, ? : (ternary), etc.
4. Control Structures in C#
if, if-else, and nested if statements: Used for conditional execution of code blocks.
switch-case statement: Provides a way to select one of many blocks of code based on the value of a
variable.