Geschreven door studenten die geslaagd zijn Direct beschikbaar na je betaling Online lezen of als PDF Verkeerd document? Gratis ruilen 4,6 TrustPilot
logo-home
College aantekeningen

Complete guide on C# Programmingin

Beoordeling
-
Verkocht
-
Pagina's
113
Geüpload op
06-12-2022
Geschreven in
2022/2023

In-Depth,complete description of C# programming from Basics to Advanced Level

Instelling
Vak

Voorbeeld van de inhoud

1



C# Programming

Table of Content


1. Introduction to C# 2


2. C# Basic Programming 3


3. C# Type Conversion 6


4. C# Variables 8


5. C# Operators 12


6. Conditional Statements 17


7. Array 18


8. Object Oriented Programming Language 21
● Encapsulation 23
● Inheritance 31
● Polymorphism 38
● Abstraction 50
● Reflection 65
● Delegates 72


9. Exception Handling 76


10. Collection &Generic Collection 86


11. Multithreading 101


12. ThreadSafe in C# 106

, 2


Introduction to C#

C# is a modern, general-purpose, object-oriented programming language developed by Microsoft.
This is designed for Common Language Infrastructure (CLI), which consists of the executable code
and runtime environment that allows use of various high-level languages to be used on different
computer platforms and architectures.
The following reasons make C# a widely used professional language:
● Modern, general-purpose programming language
● Object oriented.
● Component oriented.
● Easy to learn.
● Structured language.
● It produces efficient programs.
● It can be compiled on a variety of computer platforms.
● Part of .Net Framework.
Strong Programming Features of C#
Although C# constructs closely follow traditional high-level languages, C and C++ and being an
object-oriented programming language, it has strong resemblance with Java, it has numerous strong
programming features that make it endearing to multitude of programmers worldwide.


Following is the list of few important features:
● Automatic Garbage Collection
● Standard Library
● Assembly Versioning
● Properties and Events
● Delegates and Events Management
● Easy-to-use Generics
● Conditional Compilation
● Simple Multithreading
● LINQ and Lambda Expressions
● Integration with Windows




C# Basic Programming

C# Hello World Example

, 3


A C# program basically consists of the following parts:
● Namespace declaration
● A class
● Class methods
● Class attributes
● A Main method
● Statements & Expressions
● Comments
Let us look at a simple code that would print the words "Hello World":
using System;
namespace HelloWorldApplication
{
class HelloWorld
{
static void Main(string[] args)
{
/* my first program in C# */
Console.WriteLine("Hello World");
Console.ReadKey();
}
}
}

When the above code is compiled and executed, it produces the following result:


Hello World


Let us look at various parts of the above program:
1. The first line of the program using System; - the using keyword is used to include the
System namespace in the program. A program generally has multiple using statements.
2. The next line has the namespace declaration. A namespace is a collection of classes. The
HelloWorldApplication namespace contains the class HelloWorld.
3. The next line has a class declaration, the class HelloWorld contains the data and method
definitions that your program uses. Classes generally would contain more than one method.
Methods define the behavior of the class. However, the HelloWorld class has only one method
Main.

, 4


4. The next line defines the Main method, which is the entry point for all C# programs. The
Main method states what the class will do when executed
5. The next line /*...*/ will be ignored by the compiler and it has been put to add additional
comments in the program.
6. The Main method specifies its behavior with the statement Console.WriteLine("Hello
World");
7. WriteLine is a method of the Console class defined in the System namespace. This statement
causes the message "Hello, World!" to be displayed on the screen.
8. The last line Console.ReadKey(); is for the VS.NET Users. This makes the program wait for
a key press and it prevents the screen from running and closing quickly when the program is
launched from Visual Studio .NET.


It's worth to note the following points:
● C# is case sensitive.
● All statements and expression must end with a semicolon (;).
● The program execution starts at the Main method.
● File name could be different from the class name.


Compile & Execute a C# Program:
If you are using Visual Studio.Net for compiling and executing C# programs, take the following steps:
● Start Visual Studio.
● On the menu bar, choose File, New, Project.
● Choose Visual C# from templates.
● Choose Console Application.
● Specify a name for your project, and then choose the OK button.
● The new project appears in Solution Explorer.
● Write code in the Code Editor.
● Click the Run button or the F5 key to run the project. A Command Prompt window appears
that contains the line


Hello World.




The using Keyword
The first statement in any C# program is
using System;

Gekoppeld boek

Geschreven voor

Instelling
Vak

Documentinformatie

Geüpload op
6 december 2022
Aantal pagina's
113
Geschreven in
2022/2023
Type
College aantekeningen
Docent(en)
Kumar sir
Bevat
Alle colleges

Onderwerpen

$10.98
Krijg toegang tot het volledige document:

Verkeerd document? Gratis ruilen Binnen 14 dagen na aankoop en voor het downloaden kun je een ander document kiezen. Je kunt het bedrag gewoon opnieuw besteden.
Geschreven door studenten die geslaagd zijn
Direct beschikbaar na je betaling
Online lezen of als PDF

Maak kennis met de verkoper
Seller avatar
Rashi182

Maak kennis met de verkoper

Seller avatar
Rashi182 Acharya Institue of Technology
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
-
Lid sinds
3 jaar
Aantal volgers
0
Documenten
3
Laatst verkocht
-

0.0

0 beoordelingen

5
0
4
0
3
0
2
0
1
0

Recent door jou bekeken

Waarom studenten kiezen voor Stuvia

Gemaakt door medestudenten, geverifieerd door reviews

Kwaliteit die je kunt vertrouwen: geschreven door studenten die slaagden en beoordeeld door anderen die dit document gebruikten.

Niet tevreden? Kies een ander document

Geen zorgen! Je kunt voor hetzelfde geld direct een ander document kiezen dat beter past bij wat je zoekt.

Betaal zoals je wilt, start meteen met leren

Geen abonnement, geen verplichtingen. Betaal zoals je gewend bent via iDeal of creditcard en download je PDF-document meteen.

Student with book image

“Gekocht, gedownload en geslaagd. Zo makkelijk kan het dus zijn.”

Alisha Student

Bezig met je bronvermelding?

Maak nauwkeurige citaten in APA, MLA en Harvard met onze gratis bronnengenerator.

Bezig met je bronvermelding?

Veelgestelde vragen