[go: up one dir, main page]

0% found this document useful (0 votes)
40 views5 pages

CSharp Detailed Notes

C# is a modern, object-oriented programming language developed by Microsoft, designed for building various applications and is part of the .NET framework. The document covers key concepts including data types, variables, operators, methods, and collections like arrays and ArrayLists, as well as advanced topics such as LINQ and boxing/unboxing. It emphasizes C#'s features like garbage collection, type safety, and the use of structures and enumerations for better code organization.

Uploaded by

Nithya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views5 pages

CSharp Detailed Notes

C# is a modern, object-oriented programming language developed by Microsoft, designed for building various applications and is part of the .NET framework. The document covers key concepts including data types, variables, operators, methods, and collections like arrays and ArrayLists, as well as advanced topics such as LINQ and boxing/unboxing. It emphasizes C#'s features like garbage collection, type safety, and the use of structures and enumerations for better code organization.

Uploaded by

Nithya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

C# Programming - Detailed Notes

1. Introducing C#

C# (pronounced C-sharp) is a modern, object-oriented programming language developed by Microsoft. It is

designed to be simple, powerful, type-safe, and object-oriented. C# allows developers to build various types

of applications such as desktop, web, mobile, and games. It is part of the .NET platform and is widely used

for enterprise software development.

2. Understanding .NET

.NET is a software development framework from Microsoft. It provides a controlled environment for

developing and running applications. It includes the Common Language Runtime (CLR), which manages

memory and execution, and the Framework Class Library (FCL), which offers a collection of reusable

classes. The .NET ecosystem supports multiple languages and cross-platform development with .NET Core

and .NET 5/6/7+.

3. Overview of C#

C# is a general-purpose programming language with features like garbage collection, type safety, and

scalability. It supports object-oriented programming principles such as encapsulation, inheritance, and

polymorphism. With strong IDE support and vast libraries, it is one of the most used languages for .NET

development.

4. Literals

Literals are constant values that appear directly in the code. Examples include numeric literals (100),

floating-point literals (3.14f), character literals ('A'), string literals ("Hello World"), and boolean literals (true,

false).

5. Variables
C# Programming - Detailed Notes

Variables are used to store data in a program. Each variable must be declared with a data type. For example:

int age = 25; string name = "John";. Variable names should be meaningful and follow naming conventions.

6. Data Types

C# data types are divided into value types and reference types. Value types include int, float, char, bool, and

structs. Reference types include string, class, interface, arrays, and delegates. Nullable types allow variables

to hold null.

7. Operators

Operators are used to perform operations on variables and values. Arithmetic (+, -, *, /), relational (==, !=),

logical (&&, ||), assignment (=, +=), and bitwise (&, |) are common operator categories in C#.

8. Checked and Unchecked Operators

These operators control overflow behavior. The checked block throws an exception if overflow occurs,

whereas unchecked ignores the overflow. Example: checked { int x = int.MaxValue + 1; } causes an

exception.

9. Expressions

Expressions combine variables, literals, operators, and method calls to produce a result. For example, int

total = (price + tax) * quantity; is an expression that calculates total.

10. Branching
C# Programming - Detailed Notes

Branching allows conditional execution of code using if, else if, else, and switch statements. These help

control program flow based on conditions.

11. Looping

Loops are used to execute a block of code repeatedly. C# supports for, while, do-while, and foreach loops for

different scenarios of iteration.

12. Methods

Methods are blocks of code that perform a specific task. They help reuse code and improve modularity.

Methods can take parameters and return values.

13. Implicit and Explicit Casting

Casting is converting one data type to another. Implicit casting is automatic when no data loss occurs. Explicit

casting requires a cast operator, like (int) in (int)3.14.

14. Constant

Constants are fixed values that do not change during program execution. They are declared using the const

keyword. Example: const double PI = 3.14;

15. Arrays

Arrays store multiple values of the same type in a single variable. They are fixed in size. Example: int[]

numbers = new int[5];


C# Programming - Detailed Notes

16. Array Class

The System.Array class provides utility methods such as Sort(), Reverse(), IndexOf(), etc., to operate on

arrays.

17. ArrayList

ArrayList is a non-generic collection from System.Collections that can hold items of different data types and

resizes dynamically.

18. LINQ

Language Integrated Query (LINQ) is used to query collections using SQL-like syntax. It improves readability

and maintainability. Example: var result = from x in list where x > 10 select x;

19. String

Strings are sequences of characters. In C#, strings are immutable. Methods like Substring(), ToUpper(),

Replace(), etc., are available to manipulate strings.

20. StringBuilder

StringBuilder is used to create mutable string objects. It is more efficient than using strings when performing

many modifications.

21. Structure

Structures (struct) are value types used to group related variables. They are suitable for small data structures
C# Programming - Detailed Notes

that dont require inheritance.

22. Enumerations

Enums define a set of named constants for better code readability. Example: enum Days { Sun, Mon, Tue };

23. Boxing and Unboxing

Boxing converts a value type to an object type. Unboxing extracts the value type from the object. Example:

object obj = 10; int num = (int)obj;

You might also like