SlideShare a Scribd company logo
1 of 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

More Related Content

What's hot

Basic of the C language
Basic of the C languageBasic of the C language
Basic of the C language
Sachin Verma
 
Problem Solving Techniques
Problem Solving TechniquesProblem Solving Techniques
Problem Solving Techniques
valarpink
 
structure and union
structure and unionstructure and union
structure and union
student
 

What's hot (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
 

Viewers also liked

Dotnet presentation
Dotnet presentationDotnet presentation
Dotnet presentation
Etisbew-corp
 

Viewers also liked (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
 

Similar to Introduction to C#

Similar to 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
 

More from 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#
 

Recently uploaded

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Recently uploaded (20)

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
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 

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