SlideShare a Scribd company logo
1 of 23
Download to read offline
An Overview of C#
yasirbhutta@gmail.com
Methods
A method is a code block that contains a series of statements.
A program causes the statements to be executed by calling the method and
specifying any required method arguments.
In C#, every executed instruction is performed in the context of a method.
The Main method is the entry point for every C# application and it is called by
the common language runtime (CLR) when the program is started.
Main()
● The Main method is the entry point of a C# console application or
windows application. (Libraries and services do not require a Main
method as an entry point.).
● When the application is started, the Main method is the first method that
is invoked.
Main
● The Main method is the entry point of an .exe program; it is where the
program control starts and ends.
● Main is declared inside a class or struct. Main must be static and it should
not be public. (In the earlier example, it receives the default access of
private.) The enclosing class or struct is not required to be static.
● Main can either have a void or int return type.
● The Main method can be declared with or without a string[] parameter
that contains command-line arguments.
Namespace
● Namespaces are heavily used in C# programming in two ways.
● First, the .NET Framework uses namespaces to organize its many classes,
as follows:
System.Console.WriteLine("Hello World!");
System is a namespace and Console is a class in that namespace.
The using keyword can be used so that the complete name is not required, as
in the following example:
using System;
Console.WriteLine("Hello");
Console.WriteLine("World!");
Second, declaring your own namespaces can help you control the scope of
class and method names in larger programming projects.
namespace SampleNamespace {
class SampleClass {
public void SampleMethod()
{ System.Console.WriteLine ("SampleMethod inside SampleNamespace");
}}}
Read more ...
Control Statements
● IF
● For
Operators
Operator Meaning
<
<=
>
>=
==
!=
IF
If (condition) statement;
If (10<11) Console.WriteLine(“10 is less than 11”);
Code Block
A code block is a grouping of statements. This is done by enclosing the
statements between opening and closing curly braces.
Using Block Code
For
for (initialization; condition; iteration) statement;
Convert Class
Converts a base data type to another base data type.
Namespace: System
Convert.ToInt32 Method
● Converts a specified value to a 32-bit signed integer.
Console.ReadLine Method
● Reads the next line of characters from the standard input stream, or null
if no more lines are available.
● If the standard input device is the keyboard, the ReadLine method blocks
until the user presses the Enter key.
● Return Value type is System.String
Example: Console.ReadLine Method
Comments
// Single-Line comment
/*
Multi-Line comment
*/
Identifiers ...
● In C#, an identifier is a name assigned to a method, a variable, or any
other user defined item.
● Identifier can be one or more characters long.
● Identifier may start with any letter of the alphabet or an underscore.
Line_count, Test, x, y2, MaxLoad, _top, my_var, sample23
● However, identifiers containing two consecutive underscores, such as
max_ _value, are reserved for use by the compiler.
● Uppercase and lowercase are different; that is, to c#, myvar and MyVar
are separate names.
● 12x is invalid identifier.
Identifiers ...
● Good programming practice dictates that you choose identifiers that
reflect the meaning or usage of the items being named.
● You can use any of the reserved C# keywords as identifiers, C# does allow
you to precede a keyword with an @, allowing it to be a legal identifier.
Exercise
● Write a program to display
multiplication table of a given
number using for loop.
References
● C# Guide
● https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/na
mespaces/
● https://msdn.microsoft.com/en-us/library/system.console.readline(v=vs.1
10).aspx
● Convert Class

More Related Content

What's hot (19)

Interfaces c#
Interfaces c#Interfaces c#
Interfaces c#
 
Introduction of C#
Introduction of C#Introduction of C#
Introduction of C#
 
Switch case and looping statement
Switch case and looping statementSwitch case and looping statement
Switch case and looping statement
 
Structure
StructureStructure
Structure
 
Looping and switch cases
Looping and switch casesLooping and switch cases
Looping and switch cases
 
Understanding Interfaces
Understanding InterfacesUnderstanding Interfaces
Understanding Interfaces
 
Interface in java
Interface in javaInterface in java
Interface in java
 
Java interface
Java interfaceJava interface
Java interface
 
Learn C# Programming - Decision Making & Loops
Learn C# Programming - Decision Making & LoopsLearn C# Programming - Decision Making & Loops
Learn C# Programming - Decision Making & Loops
 
Interfaces in java
Interfaces in javaInterfaces in java
Interfaces in java
 
Java interfaces
Java interfacesJava interfaces
Java interfaces
 
Java interfaces
Java   interfacesJava   interfaces
Java interfaces
 
Java interface
Java interfaceJava interface
Java interface
 
Lexical analysis-using-lex
Lexical analysis-using-lexLexical analysis-using-lex
Lexical analysis-using-lex
 
Basic construction of c
Basic construction of cBasic construction of c
Basic construction of c
 
Basic structure of C++ program
Basic structure of C++ programBasic structure of C++ program
Basic structure of C++ program
 
C programming
C programming C programming
C programming
 
Password protected diary
Password protected diaryPassword protected diary
Password protected diary
 
Preprocessor in C
Preprocessor in CPreprocessor in C
Preprocessor in C
 

Similar to C# Overview of Methods, Namespaces, Control Statements, Operators and Identifiers

Similar to C# Overview of Methods, Namespaces, Control Statements, Operators and Identifiers (20)

Introduction to C#
Introduction to C#Introduction to C#
Introduction to C#
 
c#.pptx
c#.pptxc#.pptx
c#.pptx
 
C Programming Unit-1
C Programming Unit-1C Programming Unit-1
C Programming Unit-1
 
C# lecture 1: Introduction to Dot Net Framework
C# lecture 1: Introduction to Dot Net FrameworkC# lecture 1: Introduction to Dot Net Framework
C# lecture 1: Introduction to Dot Net Framework
 
Learning the C Language
Learning the C LanguageLearning the C Language
Learning the C Language
 
Unit-2.pptx
Unit-2.pptxUnit-2.pptx
Unit-2.pptx
 
Chapter-2 edited on Programming in Can refer this ppt
Chapter-2 edited on Programming in Can refer this pptChapter-2 edited on Programming in Can refer this ppt
Chapter-2 edited on Programming in Can refer this ppt
 
CSharp Presentation
CSharp PresentationCSharp Presentation
CSharp Presentation
 
C#ppt
C#pptC#ppt
C#ppt
 
Learn C# programming - Program Structure & Basic Syntax
Learn C# programming - Program Structure & Basic SyntaxLearn C# programming - Program Structure & Basic Syntax
Learn C# programming - Program Structure & Basic Syntax
 
Introduction%20C.pptx
Introduction%20C.pptxIntroduction%20C.pptx
Introduction%20C.pptx
 
C# AND F#
C# AND F#C# AND F#
C# AND F#
 
c# at f#
c# at f#c# at f#
c# at f#
 
C++ AND CATEGORIES OF SOFTWARE
C++ AND CATEGORIES OF SOFTWAREC++ AND CATEGORIES OF SOFTWARE
C++ AND CATEGORIES OF SOFTWARE
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
490450755-Chapter-2.ppt
490450755-Chapter-2.ppt490450755-Chapter-2.ppt
490450755-Chapter-2.ppt
 
490450755-Chapter-2.ppt
490450755-Chapter-2.ppt490450755-Chapter-2.ppt
490450755-Chapter-2.ppt
 
C++ Unit 1PPT which contains the Introduction and basic o C++ with OOOps conc...
C++ Unit 1PPT which contains the Introduction and basic o C++ with OOOps conc...C++ Unit 1PPT which contains the Introduction and basic o C++ with OOOps conc...
C++ Unit 1PPT which contains the Introduction and basic o C++ with OOOps conc...
 
Prog1-L1.pdf
Prog1-L1.pdfProg1-L1.pdf
Prog1-L1.pdf
 
Presentation 2.ppt
Presentation 2.pptPresentation 2.ppt
Presentation 2.ppt
 

Recently uploaded

Along the Lakefront, "Menacing Unknown"s
Along the Lakefront, "Menacing Unknown"sAlong the Lakefront, "Menacing Unknown"s
Along the Lakefront, "Menacing Unknown"syalehistoricalreview
 
Spiders by Slidesgo - an introduction to arachnids
Spiders by Slidesgo - an introduction to arachnidsSpiders by Slidesgo - an introduction to arachnids
Spiders by Slidesgo - an introduction to arachnidsprasan26
 
Hi FI Call Girl Ahmedabad 7397865700 Independent Call Girls
Hi FI Call Girl Ahmedabad 7397865700 Independent Call GirlsHi FI Call Girl Ahmedabad 7397865700 Independent Call Girls
Hi FI Call Girl Ahmedabad 7397865700 Independent Call Girlsssuser7cb4ff
 
EARTH DAY Slide show EARTHDAY.ORG is unwavering in our commitment to end plas...
EARTH DAY Slide show EARTHDAY.ORG is unwavering in our commitment to end plas...EARTH DAY Slide show EARTHDAY.ORG is unwavering in our commitment to end plas...
EARTH DAY Slide show EARTHDAY.ORG is unwavering in our commitment to end plas...Aqsa Yasmin
 
Call {Girls Delhi} Very Low rateVaishali 9711199012 DownLoad PDF
Call {Girls Delhi} Very Low rateVaishali 9711199012 DownLoad PDFCall {Girls Delhi} Very Low rateVaishali 9711199012 DownLoad PDF
Call {Girls Delhi} Very Low rateVaishali 9711199012 DownLoad PDFMs Riya
 
原版1:1复刻塔夫斯大学毕业证Tufts毕业证留信学历认证
原版1:1复刻塔夫斯大学毕业证Tufts毕业证留信学历认证原版1:1复刻塔夫斯大学毕业证Tufts毕业证留信学历认证
原版1:1复刻塔夫斯大学毕业证Tufts毕业证留信学历认证jdkhjh
 
VIP Call Girls Service Bandlaguda Hyderabad Call +91-8250192130
VIP Call Girls Service Bandlaguda Hyderabad Call +91-8250192130VIP Call Girls Service Bandlaguda Hyderabad Call +91-8250192130
VIP Call Girls Service Bandlaguda Hyderabad Call +91-8250192130Suhani Kapoor
 
办理La Trobe学位证(文凭证书)拉筹伯大学毕业证成绩单原版一模一样
办理La Trobe学位证(文凭证书)拉筹伯大学毕业证成绩单原版一模一样办理La Trobe学位证(文凭证书)拉筹伯大学毕业证成绩单原版一模一样
办理La Trobe学位证(文凭证书)拉筹伯大学毕业证成绩单原版一模一样umasea
 
ENVIRONMENTAL LAW ppt on laws of environmental law
ENVIRONMENTAL LAW ppt on laws of environmental lawENVIRONMENTAL LAW ppt on laws of environmental law
ENVIRONMENTAL LAW ppt on laws of environmental lawnitinraj1000000
 
9873940964 Full Enjoy 24/7 Call Girls Near Shangri La’s Eros Hotel, New Delhi
9873940964 Full Enjoy 24/7 Call Girls Near Shangri La’s Eros Hotel, New Delhi9873940964 Full Enjoy 24/7 Call Girls Near Shangri La’s Eros Hotel, New Delhi
9873940964 Full Enjoy 24/7 Call Girls Near Shangri La’s Eros Hotel, New Delhidelih Escorts
 
Soil pollution causes effects remedial measures
Soil pollution causes effects remedial measuresSoil pollution causes effects remedial measures
Soil pollution causes effects remedial measuresvasubhanot1234
 
5 Wondrous Places You Should Visit at Least Once in Your Lifetime (1).pdf
5 Wondrous Places You Should Visit at Least Once in Your Lifetime (1).pdf5 Wondrous Places You Should Visit at Least Once in Your Lifetime (1).pdf
5 Wondrous Places You Should Visit at Least Once in Your Lifetime (1).pdfsrivastavaakshat51
 
885MTAMount DMU University Bachelor's Diploma in Education
885MTAMount DMU University Bachelor's Diploma in Education885MTAMount DMU University Bachelor's Diploma in Education
885MTAMount DMU University Bachelor's Diploma in Educationz xss
 
Private Escorts Aliganj \ 9548273370 Indian Call Girls Service Lucknow ₹,9527
Private Escorts Aliganj \ 9548273370 Indian Call Girls Service Lucknow ₹,9527Private Escorts Aliganj \ 9548273370 Indian Call Girls Service Lucknow ₹,9527
Private Escorts Aliganj \ 9548273370 Indian Call Girls Service Lucknow ₹,9527nagunakhan
 
办理(Victoria毕业证书)维多利亚大学毕业证成绩单原版一比一
办理(Victoria毕业证书)维多利亚大学毕业证成绩单原版一比一办理(Victoria毕业证书)维多利亚大学毕业证成绩单原版一比一
办理(Victoria毕业证书)维多利亚大学毕业证成绩单原版一比一z xss
 
Call Girls Sarovar Portico Naraina Hotel, New Delhi 9873777170
Call Girls Sarovar Portico Naraina Hotel, New Delhi 9873777170Call Girls Sarovar Portico Naraina Hotel, New Delhi 9873777170
Call Girls Sarovar Portico Naraina Hotel, New Delhi 9873777170simranguptaxx69
 
Call Girls Ahmedabad 7397865700 Ridhima Hire Me Full Night
Call Girls Ahmedabad 7397865700 Ridhima Hire Me Full NightCall Girls Ahmedabad 7397865700 Ridhima Hire Me Full Night
Call Girls Ahmedabad 7397865700 Ridhima Hire Me Full Nightssuser7cb4ff
 

Recently uploaded (20)

Along the Lakefront, "Menacing Unknown"s
Along the Lakefront, "Menacing Unknown"sAlong the Lakefront, "Menacing Unknown"s
Along the Lakefront, "Menacing Unknown"s
 
Gandhi Nagar (Delhi) 9953330565 Escorts, Call Girls Services
Gandhi Nagar (Delhi) 9953330565 Escorts, Call Girls ServicesGandhi Nagar (Delhi) 9953330565 Escorts, Call Girls Services
Gandhi Nagar (Delhi) 9953330565 Escorts, Call Girls Services
 
Spiders by Slidesgo - an introduction to arachnids
Spiders by Slidesgo - an introduction to arachnidsSpiders by Slidesgo - an introduction to arachnids
Spiders by Slidesgo - an introduction to arachnids
 
Hi FI Call Girl Ahmedabad 7397865700 Independent Call Girls
Hi FI Call Girl Ahmedabad 7397865700 Independent Call GirlsHi FI Call Girl Ahmedabad 7397865700 Independent Call Girls
Hi FI Call Girl Ahmedabad 7397865700 Independent Call Girls
 
EARTH DAY Slide show EARTHDAY.ORG is unwavering in our commitment to end plas...
EARTH DAY Slide show EARTHDAY.ORG is unwavering in our commitment to end plas...EARTH DAY Slide show EARTHDAY.ORG is unwavering in our commitment to end plas...
EARTH DAY Slide show EARTHDAY.ORG is unwavering in our commitment to end plas...
 
Call {Girls Delhi} Very Low rateVaishali 9711199012 DownLoad PDF
Call {Girls Delhi} Very Low rateVaishali 9711199012 DownLoad PDFCall {Girls Delhi} Very Low rateVaishali 9711199012 DownLoad PDF
Call {Girls Delhi} Very Low rateVaishali 9711199012 DownLoad PDF
 
原版1:1复刻塔夫斯大学毕业证Tufts毕业证留信学历认证
原版1:1复刻塔夫斯大学毕业证Tufts毕业证留信学历认证原版1:1复刻塔夫斯大学毕业证Tufts毕业证留信学历认证
原版1:1复刻塔夫斯大学毕业证Tufts毕业证留信学历认证
 
VIP Call Girls Service Bandlaguda Hyderabad Call +91-8250192130
VIP Call Girls Service Bandlaguda Hyderabad Call +91-8250192130VIP Call Girls Service Bandlaguda Hyderabad Call +91-8250192130
VIP Call Girls Service Bandlaguda Hyderabad Call +91-8250192130
 
办理La Trobe学位证(文凭证书)拉筹伯大学毕业证成绩单原版一模一样
办理La Trobe学位证(文凭证书)拉筹伯大学毕业证成绩单原版一模一样办理La Trobe学位证(文凭证书)拉筹伯大学毕业证成绩单原版一模一样
办理La Trobe学位证(文凭证书)拉筹伯大学毕业证成绩单原版一模一样
 
ENVIRONMENTAL LAW ppt on laws of environmental law
ENVIRONMENTAL LAW ppt on laws of environmental lawENVIRONMENTAL LAW ppt on laws of environmental law
ENVIRONMENTAL LAW ppt on laws of environmental law
 
9873940964 Full Enjoy 24/7 Call Girls Near Shangri La’s Eros Hotel, New Delhi
9873940964 Full Enjoy 24/7 Call Girls Near Shangri La’s Eros Hotel, New Delhi9873940964 Full Enjoy 24/7 Call Girls Near Shangri La’s Eros Hotel, New Delhi
9873940964 Full Enjoy 24/7 Call Girls Near Shangri La’s Eros Hotel, New Delhi
 
Call Girls In R.K. Puram 9953056974 Escorts ServiCe In Delhi Ncr
Call Girls In R.K. Puram 9953056974 Escorts ServiCe In Delhi NcrCall Girls In R.K. Puram 9953056974 Escorts ServiCe In Delhi Ncr
Call Girls In R.K. Puram 9953056974 Escorts ServiCe In Delhi Ncr
 
Call Girls In { Delhi } South Extension Whatsup 9873940964 Enjoy Unlimited Pl...
Call Girls In { Delhi } South Extension Whatsup 9873940964 Enjoy Unlimited Pl...Call Girls In { Delhi } South Extension Whatsup 9873940964 Enjoy Unlimited Pl...
Call Girls In { Delhi } South Extension Whatsup 9873940964 Enjoy Unlimited Pl...
 
Soil pollution causes effects remedial measures
Soil pollution causes effects remedial measuresSoil pollution causes effects remedial measures
Soil pollution causes effects remedial measures
 
5 Wondrous Places You Should Visit at Least Once in Your Lifetime (1).pdf
5 Wondrous Places You Should Visit at Least Once in Your Lifetime (1).pdf5 Wondrous Places You Should Visit at Least Once in Your Lifetime (1).pdf
5 Wondrous Places You Should Visit at Least Once in Your Lifetime (1).pdf
 
885MTAMount DMU University Bachelor's Diploma in Education
885MTAMount DMU University Bachelor's Diploma in Education885MTAMount DMU University Bachelor's Diploma in Education
885MTAMount DMU University Bachelor's Diploma in Education
 
Private Escorts Aliganj \ 9548273370 Indian Call Girls Service Lucknow ₹,9527
Private Escorts Aliganj \ 9548273370 Indian Call Girls Service Lucknow ₹,9527Private Escorts Aliganj \ 9548273370 Indian Call Girls Service Lucknow ₹,9527
Private Escorts Aliganj \ 9548273370 Indian Call Girls Service Lucknow ₹,9527
 
办理(Victoria毕业证书)维多利亚大学毕业证成绩单原版一比一
办理(Victoria毕业证书)维多利亚大学毕业证成绩单原版一比一办理(Victoria毕业证书)维多利亚大学毕业证成绩单原版一比一
办理(Victoria毕业证书)维多利亚大学毕业证成绩单原版一比一
 
Call Girls Sarovar Portico Naraina Hotel, New Delhi 9873777170
Call Girls Sarovar Portico Naraina Hotel, New Delhi 9873777170Call Girls Sarovar Portico Naraina Hotel, New Delhi 9873777170
Call Girls Sarovar Portico Naraina Hotel, New Delhi 9873777170
 
Call Girls Ahmedabad 7397865700 Ridhima Hire Me Full Night
Call Girls Ahmedabad 7397865700 Ridhima Hire Me Full NightCall Girls Ahmedabad 7397865700 Ridhima Hire Me Full Night
Call Girls Ahmedabad 7397865700 Ridhima Hire Me Full Night
 

C# Overview of Methods, Namespaces, Control Statements, Operators and Identifiers

  • 1. An Overview of C# yasirbhutta@gmail.com
  • 2. Methods A method is a code block that contains a series of statements. A program causes the statements to be executed by calling the method and specifying any required method arguments. In C#, every executed instruction is performed in the context of a method. The Main method is the entry point for every C# application and it is called by the common language runtime (CLR) when the program is started.
  • 3. Main() ● The Main method is the entry point of a C# console application or windows application. (Libraries and services do not require a Main method as an entry point.). ● When the application is started, the Main method is the first method that is invoked.
  • 4. Main ● The Main method is the entry point of an .exe program; it is where the program control starts and ends. ● Main is declared inside a class or struct. Main must be static and it should not be public. (In the earlier example, it receives the default access of private.) The enclosing class or struct is not required to be static. ● Main can either have a void or int return type. ● The Main method can be declared with or without a string[] parameter that contains command-line arguments.
  • 5. Namespace ● Namespaces are heavily used in C# programming in two ways. ● First, the .NET Framework uses namespaces to organize its many classes, as follows: System.Console.WriteLine("Hello World!"); System is a namespace and Console is a class in that namespace.
  • 6. The using keyword can be used so that the complete name is not required, as in the following example: using System; Console.WriteLine("Hello"); Console.WriteLine("World!");
  • 7. Second, declaring your own namespaces can help you control the scope of class and method names in larger programming projects.
  • 8. namespace SampleNamespace { class SampleClass { public void SampleMethod() { System.Console.WriteLine ("SampleMethod inside SampleNamespace"); }}} Read more ...
  • 11. IF If (condition) statement; If (10<11) Console.WriteLine(“10 is less than 11”);
  • 12. Code Block A code block is a grouping of statements. This is done by enclosing the statements between opening and closing curly braces.
  • 14. For for (initialization; condition; iteration) statement;
  • 15. Convert Class Converts a base data type to another base data type. Namespace: System
  • 16. Convert.ToInt32 Method ● Converts a specified value to a 32-bit signed integer.
  • 17. Console.ReadLine Method ● Reads the next line of characters from the standard input stream, or null if no more lines are available. ● If the standard input device is the keyboard, the ReadLine method blocks until the user presses the Enter key. ● Return Value type is System.String
  • 20. Identifiers ... ● In C#, an identifier is a name assigned to a method, a variable, or any other user defined item. ● Identifier can be one or more characters long. ● Identifier may start with any letter of the alphabet or an underscore. Line_count, Test, x, y2, MaxLoad, _top, my_var, sample23 ● However, identifiers containing two consecutive underscores, such as max_ _value, are reserved for use by the compiler. ● Uppercase and lowercase are different; that is, to c#, myvar and MyVar are separate names. ● 12x is invalid identifier.
  • 21. Identifiers ... ● Good programming practice dictates that you choose identifiers that reflect the meaning or usage of the items being named. ● You can use any of the reserved C# keywords as identifiers, C# does allow you to precede a keyword with an @, allowing it to be a legal identifier.
  • 22. Exercise ● Write a program to display multiplication table of a given number using for loop.
  • 23. References ● C# Guide ● https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/na mespaces/ ● https://msdn.microsoft.com/en-us/library/system.console.readline(v=vs.1 10).aspx ● Convert Class