SlideShare ist ein Scribd-Unternehmen logo
1 von 22
   Variables
   Predefined Data Types
   Flow Control
   Enumerations
   Namespaces
   The Main() Method
   Compiling C# Files
   Console I/O
   C# Preprocessor Directives
   C# Programming Guidelines
   Syntax for Declaring a variable
      [access-specifier] datatype variable_name;
      Ex: int a;


   Initialization of Variables
      Global variables has default values
      Local variable must be explicitly initialized before use
       it.
• The scope of a variable is the region of code from
  which the variable can be accessed.
  ◦ The scope is determined by fallowing rules
     A member variable of a class is in scope for as long as
      its containing class is in scope.
     The local variable is in scope until closing brace
      indicates the end of the block.
   A constant variable is a variable whose value can
    not be changed throughout its life time.
   Syntax for Constants
    ◦ const datatype var_name=value;

    ◦ Constants have fallowing Characteristics
      They must be initialized when they are declared and it can
       never be over written.
      The value of a constant must be computable at compile time .
   Types of Data Types
    ◦ Value Types
      Value types are stored in an area known as Stack
    ◦ Reference Types
      Reference types stored in an area known as Managed Heap.
    ◦ CTS Types
      The basic predefined types recognized by C# are not
       intrinsic to the language but are part of .NET Framework.
   Conditional Statements
      When you use a conditional statement, you can specify
       a condition and one or more commands to be
       executed, depending on whether the condition is
       evaluated to true or false.
      If, if-else, switch.
   Loops
      The loop executes a statement or a block of
       statements repeatedly until a specified expression
       evaluates to false.
      for, while, do-while, foreach.
   Jump Statements
    ◦ Branching is performed using jump statements,
      which cause an immediate transfer of the program
      control.
    ◦ The following keywords are used in jump
      statements:
       break
       return
       continue
       goto
       throw
   An enumeration type (also named an enum) provides an
    efficient way to define a set of named integral constants
    that may be assigned to a variable.
   The enum keyword is used to declare an enumeration, a
    distinct type that consists of a set of named constants
    called the enumerator list.
    ◦ Ex: enum Days { Sunday, Monday, Tuesday, Wednesday, Thursday,
      Friday, Saturday }; //by default Sunday=0…Saturday=6
    ◦ enum Months : byte { Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep,
      Oct, Nov, Dec };
   By default the underlying type of each element in the enum
    is int. You can specify another integral numeric type by
    using a colon, as shown in the previous example.
   By default, the first enumerator has the value 0, and the
    value of each successive enumerator is increased by 1.
   Namespaces provide a way of organizing related
    classes and other types.
   The namespace keyword is used to declare a
    scope. This namespace scope lets you organize
    code and gives you a way to create globally
    unique types.
   Syntax to create namespaces
      namespace namespace_name
       {
       class class_name{…..}
       }
   using Directive
   The using directive has two uses:
    ◦ To allow the use of types in a namespace so that
      you do not have to qualify the use of a type in that
      namespace:
      using System.Text;
    ◦ To create an alias for a namespace or a type. This is
      called a using alias directive.
      using Project = PC.MyCompany.Project;
   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.
   There can only be one entry point in a C#
    program.
   If you have more than one class that has a Main
    method, you must compile your program with the
    /main compiler option to specify which Main
    method to use as the entry point.
   Main must be static and it should not be
    public.
   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.
   The parameter of the Main method is a string
    array that represents the command-line
    arguments.
    ◦ static void Main(string[] args) {….}
   Usually you check for the existence of the
    arguments by testing the Length property.
    ◦ if (args.Length == 0) {//Inform user}
   Console class represents the standard input,
    output, and error streams for console
    applications.
   This class cannot be inherited.
   Some Methods in Console Class are
    ◦   Write()
    ◦   WriteLine()
    ◦   ReadLine()
    ◦   Clear()
   We can also set the position of the text in
    console
   Internal Comments
    ◦ C# uses traditional C-type single-line(//…) and
      Multiline (/*…………..*/)
   XML Documentation
    ◦ All XML comments begin with three forward slashes (///).
      The first two slashes signify a comment and tell the
      compiler to ignore the text that follows. The third slash
      tells the parser that this is an XML comment and should be
      handled appropriately.
    ◦ Ex:
        /// <summary>
        ///
        /// </summary>
        /// <param name="strFilePath"></param>
   The tags recognized by the compiler
    <c>         The text you would like to indicate as code

    <code>      Marks multiple lines as code

    <example>   Marks up a code Example

    <include>   Includes comments from another documentation
                file
    <list>      Inserts a list into the documentation

    <param>     Marks up a method parameter

    <value>     Describes a property

    <summary>   Provides a short summary of a type or member
   C# also includes a number of commands that are known as
    preprocessor directives.
   These commands never actually get translated to any
    commands in your executable code, but instead they affect
    aspects of compilation process.
#define       Tells the compiler that a symbol with the given name exists.

#undef        Removes the definition of a symbol.

#if, #elif,   These directives inform the compiler whether to compile
#else and     a block of code
#endif
#warning      These will respectively cause a warning or an error to be
and #error    raised when the compiler encounters them.
#region and   These are used to indicate that a certain block of code is
#endregion    to be treated as a single block
#line         This can be used to alter the filename and line number
              information that is output by the compiler in warning or
              error messages
#pragma       This can suppress or restore specific compiler warnings.
   Identifiers
    ◦ Identifiers are names you given to variables and
      user-defined types.
   Rules for Identifiers
    ◦ They must begin with a letter or underscore,
      although they can contain numeric characteristics
    ◦ You can’t use c# keywords as identifiers

Weitere ähnliche Inhalte

Was ist angesagt?

Basic of the C language
Basic of the C languageBasic of the C language
Basic of the C languageSachin Verma
 
Basics of C programming
Basics of C programmingBasics of C programming
Basics of C programmingavikdhupar
 
StandardsandStylesCProgramming
StandardsandStylesCProgrammingStandardsandStylesCProgramming
StandardsandStylesCProgrammingKaushik Patidar
 
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 SyntaxEng Teong Cheah
 
Programming in C Presentation upto FILE
Programming in C Presentation upto FILEProgramming in C Presentation upto FILE
Programming in C Presentation upto FILEDipta Saha
 
Variable and constants in Vb.NET
Variable and constants in Vb.NETVariable and constants in Vb.NET
Variable and constants in Vb.NETJaya Kumari
 
Problem Solving Techniques
Problem Solving TechniquesProblem Solving Techniques
Problem Solving Techniquesvalarpink
 
Escape Sequences and Variables
Escape Sequences and VariablesEscape Sequences and Variables
Escape Sequences and Variablesyarkhosh
 
pointer, structure ,union and intro to file handling
pointer, structure ,union and intro to file handlingpointer, structure ,union and intro to file handling
pointer, structure ,union and intro to file handlingRai University
 
Introduction to c
Introduction to cIntroduction to c
Introduction to cAjeet Kumar
 
structure and union
structure and unionstructure and union
structure and unionstudent
 

Was ist angesagt? (18)

Basic of the C language
Basic of the C languageBasic of the C language
Basic of the C language
 
Basics of C programming
Basics of C programmingBasics of C programming
Basics of C programming
 
StandardsandStylesCProgramming
StandardsandStylesCProgrammingStandardsandStylesCProgramming
StandardsandStylesCProgramming
 
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
 
Opps concept
Opps conceptOpps concept
Opps concept
 
Programming in C Presentation upto FILE
Programming in C Presentation upto FILEProgramming in C Presentation upto FILE
Programming in C Presentation upto FILE
 
C notes.pdf
C notes.pdfC notes.pdf
C notes.pdf
 
OOP Poster Presentation
OOP Poster PresentationOOP Poster Presentation
OOP Poster Presentation
 
Variable and constants in Vb.NET
Variable and constants in Vb.NETVariable and constants in Vb.NET
Variable and constants in Vb.NET
 
Pl sql programme
Pl sql programmePl sql programme
Pl sql programme
 
SPL 5 | scanf in C
SPL 5 | scanf in CSPL 5 | scanf in C
SPL 5 | scanf in C
 
Problem Solving Techniques
Problem Solving TechniquesProblem Solving Techniques
Problem Solving Techniques
 
Ma3696 Lecture 3
Ma3696 Lecture 3Ma3696 Lecture 3
Ma3696 Lecture 3
 
overview of c#
overview of c#overview of c#
overview of c#
 
Escape Sequences and Variables
Escape Sequences and VariablesEscape Sequences and Variables
Escape Sequences and Variables
 
pointer, structure ,union and intro to file handling
pointer, structure ,union and intro to file handlingpointer, structure ,union and intro to file handling
pointer, structure ,union and intro to file handling
 
Introduction to c
Introduction to cIntroduction to c
Introduction to c
 
structure and union
structure and unionstructure and union
structure and union
 

Andere mochten auch

Inovies web design company profile
Inovies web design company profileInovies web design company profile
Inovies web design company profileinovies
 
Dotnet presentation
Dotnet presentationDotnet presentation
Dotnet presentationEtisbew-corp
 
Introduction To .Net Compact Framework and SQL Server CE Development
Introduction To .Net Compact Framework and SQL Server CE DevelopmentIntroduction To .Net Compact Framework and SQL Server CE Development
Introduction To .Net Compact Framework and SQL Server CE Developmentchristopherfairbairn
 
How to Design Product with Cognitive Computing and Big Data
How to Design Product with Cognitive Computing and Big DataHow to Design Product with Cognitive Computing and Big Data
How to Design Product with Cognitive Computing and Big DataJason Smith
 
Cognitive radio networks
Cognitive radio networksCognitive radio networks
Cognitive radio networksVatsala Sharma
 
Introduction to .NET Programming
Introduction to .NET ProgrammingIntroduction to .NET Programming
Introduction to .NET ProgrammingKarthikeyan Mkr
 
Introduction to .NET Framework and C# (English)
Introduction to .NET Framework and C# (English)Introduction to .NET Framework and C# (English)
Introduction to .NET Framework and C# (English)Vangos Pterneas
 
Etisbew ColdFusion Expertise
Etisbew ColdFusion Expertise Etisbew ColdFusion Expertise
Etisbew ColdFusion Expertise David Colmer
 
IBM Big Data Analytics - Cognitive Computing and Watson - Findability Day 2014
IBM Big Data Analytics - Cognitive Computing and Watson - Findability Day 2014IBM Big Data Analytics - Cognitive Computing and Watson - Findability Day 2014
IBM Big Data Analytics - Cognitive Computing and Watson - Findability Day 2014Findwise
 
IBM Watson Ecosystem roadshow - Chicago 4-2-14
IBM Watson Ecosystem roadshow - Chicago 4-2-14IBM Watson Ecosystem roadshow - Chicago 4-2-14
IBM Watson Ecosystem roadshow - Chicago 4-2-14cheribergeron
 
Introduction To Dotnet
Introduction To DotnetIntroduction To Dotnet
Introduction To DotnetSAMIR BHOGAYTA
 
Introduction to .net framework
Introduction to .net frameworkIntroduction to .net framework
Introduction to .net frameworkArun Prasad
 
Cognitive radio networks
Cognitive radio networksCognitive radio networks
Cognitive radio networksAmeer Sameer
 

Andere mochten auch (20)

Dot net
Dot netDot net
Dot net
 
Etggs opensource
Etggs opensourceEtggs opensource
Etggs opensource
 
Inovies web design company profile
Inovies web design company profileInovies web design company profile
Inovies web design company profile
 
Dotnet presentation
Dotnet presentationDotnet presentation
Dotnet presentation
 
Dot Net Introduction
Dot Net IntroductionDot Net Introduction
Dot Net Introduction
 
.NET Introduction
.NET Introduction.NET Introduction
.NET Introduction
 
Basic Introduction of Dot Net Programming
Basic Introduction of Dot Net ProgrammingBasic Introduction of Dot Net Programming
Basic Introduction of Dot Net Programming
 
Introduction To .Net Compact Framework and SQL Server CE Development
Introduction To .Net Compact Framework and SQL Server CE DevelopmentIntroduction To .Net Compact Framework and SQL Server CE Development
Introduction To .Net Compact Framework and SQL Server CE Development
 
How to Design Product with Cognitive Computing and Big Data
How to Design Product with Cognitive Computing and Big DataHow to Design Product with Cognitive Computing and Big Data
How to Design Product with Cognitive Computing and Big Data
 
Cognitive radio networks
Cognitive radio networksCognitive radio networks
Cognitive radio networks
 
Introduction to .NET Programming
Introduction to .NET ProgrammingIntroduction to .NET Programming
Introduction to .NET Programming
 
Dotnet basics
Dotnet basicsDotnet basics
Dotnet basics
 
Introduction to .NET Framework and C# (English)
Introduction to .NET Framework and C# (English)Introduction to .NET Framework and C# (English)
Introduction to .NET Framework and C# (English)
 
Introduction to .NET Framework
Introduction to .NET FrameworkIntroduction to .NET Framework
Introduction to .NET Framework
 
Etisbew ColdFusion Expertise
Etisbew ColdFusion Expertise Etisbew ColdFusion Expertise
Etisbew ColdFusion Expertise
 
IBM Big Data Analytics - Cognitive Computing and Watson - Findability Day 2014
IBM Big Data Analytics - Cognitive Computing and Watson - Findability Day 2014IBM Big Data Analytics - Cognitive Computing and Watson - Findability Day 2014
IBM Big Data Analytics - Cognitive Computing and Watson - Findability Day 2014
 
IBM Watson Ecosystem roadshow - Chicago 4-2-14
IBM Watson Ecosystem roadshow - Chicago 4-2-14IBM Watson Ecosystem roadshow - Chicago 4-2-14
IBM Watson Ecosystem roadshow - Chicago 4-2-14
 
Introduction To Dotnet
Introduction To DotnetIntroduction To Dotnet
Introduction To Dotnet
 
Introduction to .net framework
Introduction to .net frameworkIntroduction to .net framework
Introduction to .net framework
 
Cognitive radio networks
Cognitive radio networksCognitive radio networks
Cognitive radio networks
 

Ähnlich wie Introduction to C#

Ähnlich wie Introduction to C# (20)

c# at f#
c# at f#c# at f#
c# at f#
 
C# AND F#
C# AND F#C# AND F#
C# AND F#
 
Unit 1 question and answer
Unit 1 question and answerUnit 1 question and answer
Unit 1 question and answer
 
Notes(1).pptx
Notes(1).pptxNotes(1).pptx
Notes(1).pptx
 
Esoft Metro Campus - Certificate in c / c++ programming
Esoft Metro Campus - Certificate in c / c++ programmingEsoft Metro Campus - Certificate in c / c++ programming
Esoft Metro Campus - Certificate in c / c++ programming
 
C presentation! BATRA COMPUTER CENTRE
C presentation! BATRA  COMPUTER  CENTRE C presentation! BATRA  COMPUTER  CENTRE
C presentation! BATRA COMPUTER CENTRE
 
lec 2.pptx
lec 2.pptxlec 2.pptx
lec 2.pptx
 
Variables in C and C++ Language
Variables in C and C++ LanguageVariables in C and C++ Language
Variables in C and C++ Language
 
C#
C#C#
C#
 
Aniket tore
Aniket toreAniket tore
Aniket tore
 
fds unit1.docx
fds unit1.docxfds unit1.docx
fds unit1.docx
 
C language 3
C language 3C language 3
C language 3
 
C Language (All Concept)
C Language (All Concept)C Language (All Concept)
C Language (All Concept)
 
unit2.pptx
unit2.pptxunit2.pptx
unit2.pptx
 
c#.pptx
c#.pptxc#.pptx
c#.pptx
 
Lecture2_MCS4_Evening.pptx
Lecture2_MCS4_Evening.pptxLecture2_MCS4_Evening.pptx
Lecture2_MCS4_Evening.pptx
 
CSharp Presentation
CSharp PresentationCSharp Presentation
CSharp Presentation
 
Learning the C Language
Learning the C LanguageLearning the C Language
Learning the C Language
 
history of c.ppt
history of c.ppthistory of c.ppt
history of c.ppt
 
C_plus_plus
C_plus_plusC_plus_plus
C_plus_plus
 

Mehr von Raghuveer Guthikonda (8)

C# String
C# StringC# String
C# String
 
C# Delegates
C# DelegatesC# Delegates
C# Delegates
 
Operators & Casts
Operators & CastsOperators & Casts
Operators & Casts
 
Arrays C#
Arrays C#Arrays C#
Arrays C#
 
Generics C#
Generics C#Generics C#
Generics C#
 
Inheritance C#
Inheritance C#Inheritance C#
Inheritance C#
 
Objects and Types C#
Objects and Types C#Objects and Types C#
Objects and Types C#
 
Regex in C#
Regex in C#Regex in C#
Regex in C#
 

Kürzlich hochgeladen

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 

Kürzlich hochgeladen (20)

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

Introduction to C#

  • 1.
  • 2. Variables  Predefined Data Types  Flow Control  Enumerations  Namespaces  The Main() Method  Compiling C# Files  Console I/O  C# Preprocessor Directives  C# Programming Guidelines
  • 3. Syntax for Declaring a variable  [access-specifier] datatype variable_name;  Ex: int a;  Initialization of Variables  Global variables has default values  Local variable must be explicitly initialized before use it.
  • 4. • The scope of a variable is the region of code from which the variable can be accessed. ◦ The scope is determined by fallowing rules  A member variable of a class is in scope for as long as its containing class is in scope.  The local variable is in scope until closing brace indicates the end of the block.
  • 5. A constant variable is a variable whose value can not be changed throughout its life time.  Syntax for Constants ◦ const datatype var_name=value; ◦ Constants have fallowing Characteristics  They must be initialized when they are declared and it can never be over written.  The value of a constant must be computable at compile time .
  • 6. Types of Data Types ◦ Value Types  Value types are stored in an area known as Stack ◦ Reference Types  Reference types stored in an area known as Managed Heap. ◦ CTS Types  The basic predefined types recognized by C# are not intrinsic to the language but are part of .NET Framework.
  • 7.
  • 8. Conditional Statements  When you use a conditional statement, you can specify a condition and one or more commands to be executed, depending on whether the condition is evaluated to true or false.  If, if-else, switch.  Loops  The loop executes a statement or a block of statements repeatedly until a specified expression evaluates to false.  for, while, do-while, foreach.
  • 9. Jump Statements ◦ Branching is performed using jump statements, which cause an immediate transfer of the program control. ◦ The following keywords are used in jump statements:  break  return  continue  goto  throw
  • 10. An enumeration type (also named an enum) provides an efficient way to define a set of named integral constants that may be assigned to a variable.  The enum keyword is used to declare an enumeration, a distinct type that consists of a set of named constants called the enumerator list. ◦ Ex: enum Days { Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday }; //by default Sunday=0…Saturday=6 ◦ enum Months : byte { Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec };  By default the underlying type of each element in the enum is int. You can specify another integral numeric type by using a colon, as shown in the previous example.  By default, the first enumerator has the value 0, and the value of each successive enumerator is increased by 1.
  • 11. Namespaces provide a way of organizing related classes and other types.  The namespace keyword is used to declare a scope. This namespace scope lets you organize code and gives you a way to create globally unique types.  Syntax to create namespaces  namespace namespace_name { class class_name{…..} }
  • 12. using Directive  The using directive has two uses: ◦ To allow the use of types in a namespace so that you do not have to qualify the use of a type in that namespace:  using System.Text; ◦ To create an alias for a namespace or a type. This is called a using alias directive.  using Project = PC.MyCompany.Project;
  • 13. 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.  There can only be one entry point in a C# program.  If you have more than one class that has a Main method, you must compile your program with the /main compiler option to specify which Main method to use as the entry point.
  • 14. Main must be static and it should not be public.  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.
  • 15. The parameter of the Main method is a string array that represents the command-line arguments. ◦ static void Main(string[] args) {….}  Usually you check for the existence of the arguments by testing the Length property. ◦ if (args.Length == 0) {//Inform user}
  • 16.
  • 17. Console class represents the standard input, output, and error streams for console applications.  This class cannot be inherited.  Some Methods in Console Class are ◦ Write() ◦ WriteLine() ◦ ReadLine() ◦ Clear()  We can also set the position of the text in console
  • 18. Internal Comments ◦ C# uses traditional C-type single-line(//…) and Multiline (/*…………..*/)  XML Documentation ◦ All XML comments begin with three forward slashes (///). The first two slashes signify a comment and tell the compiler to ignore the text that follows. The third slash tells the parser that this is an XML comment and should be handled appropriately. ◦ Ex: /// <summary> /// /// </summary> /// <param name="strFilePath"></param>
  • 19. The tags recognized by the compiler <c> The text you would like to indicate as code <code> Marks multiple lines as code <example> Marks up a code Example <include> Includes comments from another documentation file <list> Inserts a list into the documentation <param> Marks up a method parameter <value> Describes a property <summary> Provides a short summary of a type or member
  • 20. C# also includes a number of commands that are known as preprocessor directives.  These commands never actually get translated to any commands in your executable code, but instead they affect aspects of compilation process.
  • 21. #define Tells the compiler that a symbol with the given name exists. #undef Removes the definition of a symbol. #if, #elif, These directives inform the compiler whether to compile #else and a block of code #endif #warning These will respectively cause a warning or an error to be and #error raised when the compiler encounters them. #region and These are used to indicate that a certain block of code is #endregion to be treated as a single block #line This can be used to alter the filename and line number information that is output by the compiler in warning or error messages #pragma This can suppress or restore specific compiler warnings.
  • 22. Identifiers ◦ Identifiers are names you given to variables and user-defined types.  Rules for Identifiers ◦ They must begin with a letter or underscore, although they can contain numeric characteristics ◦ You can’t use c# keywords as identifiers