SlideShare a Scribd company logo
1 of 21
Overview of C#
Overview
 Structure of a C# Program
 Basic Input/Output Operations
 Recommended Practices
 Compiling, Running, and Debugging
Structure of a C# Program
 Hello, World
 The Class
 The Main Method
 The using Directive and the System Namespace
 Demonstration: Using Visual Studio to Create
a C# Program
Hello, World
using System;
class Hello
{
public static void Main()
{
Console.WriteLine("Hello, World");
}
}
The Class
 A C# application is a collection of classes, structures,
and types
 A class Is a set of data and methods
 Syntax
 A C# application can consist of many files
 A class cannot span multiple files
class name
{
...
}
The Main Method
 When writing Main, you should:
 Use an uppercase “M”, as in “Main”
 Designate one Main as the entry point to the program
 Declare Main as public static void Main
 Multiple classes can have a Main
 When Main finishes, or returns, the application quits
The using Directive and the
System Namespace
 The .NET Framework provides many utility classes
 Organized into namespaces
 System is the most commonly used namespace
 Refer to classes by their namespace
 The using directive
System.Console.WriteLine("Hello, World");
using System;
…
Console.WriteLine("Hello, World");
Basic Input/Output Operations
 The Console Class
 Write and WriteLine Methods
 Read and ReadLine Methods
The Console Class
 Provides access to the standard input, standard output,
and standard error streams
 Only meaningful for console applications
 Standard input – keyboard
 Standard output – screen
 Standard error – screen
 All streams may be redirected
Write and WriteLine Methods
 Console.Write and Console.WriteLine display information
on the console screen
 WriteLine outputs a line feed/carriage return
 Both methods are overloaded
 A format string and parameters can be used
 Text formatting
 Numeric formatting
Read and ReadLine Methods
 Console.Read and Console.ReadLine read user input
 Read reads the next character
 ReadLine reads the entire input line
Recommended Practices
 Commenting Applications
 Generating XML Documentation
 Demonstration: Generating and Viewing XML
Documentation
 Exception Handling
Commenting Applications
 Comments are important
 A well-commented application permits a developer to fully
understand the structure of the application
 Single-line comments
 Multiple-line comments
/* Find the higher root of the
quadratic equation */
x = (…);
// Get the user’s name
Console.WriteLine("What is your name? ");
name = Console.ReadLine( );
Generating XML Documentation
/// <summary> The Hello class prints a greeting
/// on the screen
/// </summary>
class Hello
{
/// <remarks> We use console-based I/O.
/// For more information about WriteLine, see
/// <seealso cref="System.Console.WriteLine"/>
/// </remarks>
public static void Main( )
{
Console.WriteLine("Hello, World");
}
}
Exception Handling
using System;
public class Hello
{
public static void Main(string[ ] args)
{
try{
Console.WriteLine(args[0]);
}
catch (Exception e) {
Console.WriteLine("Exception at
{0}", e.StackTrace);
}
}
}
Compiling, Running, and Debugging
 Invoking the Compiler
 Running the Application
 Demonstration: Compiling and Running
a C# Program
 Debugging
 Demonstration: Using the Visual Studio Debugger
 The SDK Tools
 Demonstration: Using ILDASM
Invoking the Compiler
 Common Compiler Switches
 Compiling from the Command Line
 Compiling from Visual Studio
 Locating Errors
Running the Application
 Running from the Command Line
 Type the name of the application
 Running from Visual Studio
 Click Start Without Debugging on the Debug menu
Debugging
 Exceptions and JIT Debugging
 The Visual Studio Debugger
 Setting breakpoints and watches
 Stepping through code
 Examining and modifying variables
The SDK Tools
 General Tools and Utilities
 Windows Forms Design Tools and Utilities
 Security Tools and Utilities
 Configuration and Deployment Tools and Utilities
Review
 Structure of a C# Program
 Basic Input/Output Operations
 Recommended Practices
 Compiling, Running, and Debugging

More Related Content

Similar to Module 2: Overview of c#

JavaScript guide 2020 Learn JavaScript
JavaScript guide 2020 Learn JavaScriptJavaScript guide 2020 Learn JavaScript
JavaScript guide 2020 Learn JavaScriptLaurence Svekis ✔
 
Object-oriented programming (OOP) with Complete understanding modules
Object-oriented programming (OOP) with Complete understanding modulesObject-oriented programming (OOP) with Complete understanding modules
Object-oriented programming (OOP) with Complete understanding modulesDurgesh Singh
 
csharp_dotnet_adnanreza.pptx
csharp_dotnet_adnanreza.pptxcsharp_dotnet_adnanreza.pptx
csharp_dotnet_adnanreza.pptxPoornima E.G.
 
1 CMPS 12M Introduction to Data Structures Lab La.docx
1 CMPS 12M Introduction to Data Structures Lab La.docx1 CMPS 12M Introduction to Data Structures Lab La.docx
1 CMPS 12M Introduction to Data Structures Lab La.docxtarifarmarie
 
Visula C# Programming Lecture 8
Visula C# Programming Lecture 8Visula C# Programming Lecture 8
Visula C# Programming Lecture 8Abou Bakr Ashraf
 
The Ring programming language version 1.5.3 book - Part 16 of 184
The Ring programming language version 1.5.3 book - Part 16 of 184The Ring programming language version 1.5.3 book - Part 16 of 184
The Ring programming language version 1.5.3 book - Part 16 of 184Mahmoud Samir Fayed
 
.NET and C# introduction
.NET and C# introduction.NET and C# introduction
.NET and C# introductionPeter Gfader
 
Plug-in Architectures
Plug-in ArchitecturesPlug-in Architectures
Plug-in Architectureselliando dias
 
The Ring programming language version 1.4 book - Part 4 of 30
The Ring programming language version 1.4 book - Part 4 of 30The Ring programming language version 1.4 book - Part 4 of 30
The Ring programming language version 1.4 book - Part 4 of 30Mahmoud Samir Fayed
 
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
 

Similar to Module 2: Overview of c# (20)

C++ basics
C++ basicsC++ basics
C++ basics
 
Session Four C#
Session Four C# Session Four C#
Session Four C#
 
Srgoc dotnet
Srgoc dotnetSrgoc dotnet
Srgoc dotnet
 
JavaScript guide 2020 Learn JavaScript
JavaScript guide 2020 Learn JavaScriptJavaScript guide 2020 Learn JavaScript
JavaScript guide 2020 Learn JavaScript
 
Object-oriented programming (OOP) with Complete understanding modules
Object-oriented programming (OOP) with Complete understanding modulesObject-oriented programming (OOP) with Complete understanding modules
Object-oriented programming (OOP) with Complete understanding modules
 
Session4 csharp
Session4 csharpSession4 csharp
Session4 csharp
 
csharp_dotnet_adnanreza.pptx
csharp_dotnet_adnanreza.pptxcsharp_dotnet_adnanreza.pptx
csharp_dotnet_adnanreza.pptx
 
C#.net
C#.netC#.net
C#.net
 
1 CMPS 12M Introduction to Data Structures Lab La.docx
1 CMPS 12M Introduction to Data Structures Lab La.docx1 CMPS 12M Introduction to Data Structures Lab La.docx
1 CMPS 12M Introduction to Data Structures Lab La.docx
 
C++
C++C++
C++
 
Prog1-L1.pdf
Prog1-L1.pdfProg1-L1.pdf
Prog1-L1.pdf
 
Visula C# Programming Lecture 8
Visula C# Programming Lecture 8Visula C# Programming Lecture 8
Visula C# Programming Lecture 8
 
Dotnet basics
Dotnet basicsDotnet basics
Dotnet basics
 
The Ring programming language version 1.5.3 book - Part 16 of 184
The Ring programming language version 1.5.3 book - Part 16 of 184The Ring programming language version 1.5.3 book - Part 16 of 184
The Ring programming language version 1.5.3 book - Part 16 of 184
 
Cordovilla
CordovillaCordovilla
Cordovilla
 
.NET and C# introduction
.NET and C# introduction.NET and C# introduction
.NET and C# introduction
 
Intro.net
Intro.netIntro.net
Intro.net
 
Plug-in Architectures
Plug-in ArchitecturesPlug-in Architectures
Plug-in Architectures
 
The Ring programming language version 1.4 book - Part 4 of 30
The Ring programming language version 1.4 book - Part 4 of 30The Ring programming language version 1.4 book - Part 4 of 30
The Ring programming language version 1.4 book - Part 4 of 30
 
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
 

More from Prem Kumar Badri

Module 14 properties and indexers
Module 14 properties and indexersModule 14 properties and indexers
Module 14 properties and indexersPrem Kumar Badri
 
Module 12 aggregation, namespaces, and advanced scope
Module 12 aggregation, namespaces, and advanced scopeModule 12 aggregation, namespaces, and advanced scope
Module 12 aggregation, namespaces, and advanced scopePrem Kumar Badri
 
Module 13 operators, delegates, and events
Module 13 operators, delegates, and eventsModule 13 operators, delegates, and events
Module 13 operators, delegates, and eventsPrem Kumar Badri
 
Module 10 : creating and destroying objects
Module 10 : creating and destroying objectsModule 10 : creating and destroying objects
Module 10 : creating and destroying objectsPrem Kumar Badri
 
Module 9 : using reference type variables
Module 9 : using reference type variablesModule 9 : using reference type variables
Module 9 : using reference type variablesPrem Kumar Badri
 
Module 8 : Implementing collections and generics
Module 8 : Implementing collections and genericsModule 8 : Implementing collections and generics
Module 8 : Implementing collections and genericsPrem Kumar Badri
 
Module 6 : Essentials of Object Oriented Programming
Module 6 : Essentials of Object Oriented ProgrammingModule 6 : Essentials of Object Oriented Programming
Module 6 : Essentials of Object Oriented ProgrammingPrem Kumar Badri
 
Module 5 : Statements & Exceptions
Module 5 : Statements & ExceptionsModule 5 : Statements & Exceptions
Module 5 : Statements & ExceptionsPrem Kumar Badri
 
Module 4 : methods & parameters
Module 4 : methods & parametersModule 4 : methods & parameters
Module 4 : methods & parametersPrem Kumar Badri
 
Module 3 : using value type variables
Module 3 : using value type variablesModule 3 : using value type variables
Module 3 : using value type variablesPrem Kumar Badri
 
Module 1 : Overview of the Microsoft .NET Platform
Module 1 : Overview of the Microsoft .NET PlatformModule 1 : Overview of the Microsoft .NET Platform
Module 1 : Overview of the Microsoft .NET PlatformPrem Kumar Badri
 
C# Non generics collection
C# Non generics collectionC# Non generics collection
C# Non generics collectionPrem Kumar Badri
 

More from Prem Kumar Badri (20)

Module 15 attributes
Module 15 attributesModule 15 attributes
Module 15 attributes
 
Module 14 properties and indexers
Module 14 properties and indexersModule 14 properties and indexers
Module 14 properties and indexers
 
Module 12 aggregation, namespaces, and advanced scope
Module 12 aggregation, namespaces, and advanced scopeModule 12 aggregation, namespaces, and advanced scope
Module 12 aggregation, namespaces, and advanced scope
 
Module 13 operators, delegates, and events
Module 13 operators, delegates, and eventsModule 13 operators, delegates, and events
Module 13 operators, delegates, and events
 
Module 11 : Inheritance
Module 11 : InheritanceModule 11 : Inheritance
Module 11 : Inheritance
 
Module 10 : creating and destroying objects
Module 10 : creating and destroying objectsModule 10 : creating and destroying objects
Module 10 : creating and destroying objects
 
Module 9 : using reference type variables
Module 9 : using reference type variablesModule 9 : using reference type variables
Module 9 : using reference type variables
 
Module 8 : Implementing collections and generics
Module 8 : Implementing collections and genericsModule 8 : Implementing collections and generics
Module 8 : Implementing collections and generics
 
Module 7 : Arrays
Module 7 : ArraysModule 7 : Arrays
Module 7 : Arrays
 
Module 6 : Essentials of Object Oriented Programming
Module 6 : Essentials of Object Oriented ProgrammingModule 6 : Essentials of Object Oriented Programming
Module 6 : Essentials of Object Oriented Programming
 
Module 5 : Statements & Exceptions
Module 5 : Statements & ExceptionsModule 5 : Statements & Exceptions
Module 5 : Statements & Exceptions
 
Module 4 : methods & parameters
Module 4 : methods & parametersModule 4 : methods & parameters
Module 4 : methods & parameters
 
Module 3 : using value type variables
Module 3 : using value type variablesModule 3 : using value type variables
Module 3 : using value type variables
 
Module 1 : Overview of the Microsoft .NET Platform
Module 1 : Overview of the Microsoft .NET PlatformModule 1 : Overview of the Microsoft .NET Platform
Module 1 : Overview of the Microsoft .NET Platform
 
C# Non generics collection
C# Non generics collectionC# Non generics collection
C# Non generics collection
 
C# Multi threading
C# Multi threadingC# Multi threading
C# Multi threading
 
C# Method overloading
C# Method overloadingC# Method overloading
C# Method overloading
 
C# Inheritance
C# InheritanceC# Inheritance
C# Inheritance
 
C# Generic collections
C# Generic collectionsC# Generic collections
C# Generic collections
 
C# Global Assembly Cache
C# Global Assembly CacheC# Global Assembly Cache
C# Global Assembly Cache
 

Recently uploaded

Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 

Recently uploaded (20)

Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 

Module 2: Overview of c#

  • 2. Overview  Structure of a C# Program  Basic Input/Output Operations  Recommended Practices  Compiling, Running, and Debugging
  • 3. Structure of a C# Program  Hello, World  The Class  The Main Method  The using Directive and the System Namespace  Demonstration: Using Visual Studio to Create a C# Program
  • 4. Hello, World using System; class Hello { public static void Main() { Console.WriteLine("Hello, World"); } }
  • 5. The Class  A C# application is a collection of classes, structures, and types  A class Is a set of data and methods  Syntax  A C# application can consist of many files  A class cannot span multiple files class name { ... }
  • 6. The Main Method  When writing Main, you should:  Use an uppercase “M”, as in “Main”  Designate one Main as the entry point to the program  Declare Main as public static void Main  Multiple classes can have a Main  When Main finishes, or returns, the application quits
  • 7. The using Directive and the System Namespace  The .NET Framework provides many utility classes  Organized into namespaces  System is the most commonly used namespace  Refer to classes by their namespace  The using directive System.Console.WriteLine("Hello, World"); using System; … Console.WriteLine("Hello, World");
  • 8. Basic Input/Output Operations  The Console Class  Write and WriteLine Methods  Read and ReadLine Methods
  • 9. The Console Class  Provides access to the standard input, standard output, and standard error streams  Only meaningful for console applications  Standard input – keyboard  Standard output – screen  Standard error – screen  All streams may be redirected
  • 10. Write and WriteLine Methods  Console.Write and Console.WriteLine display information on the console screen  WriteLine outputs a line feed/carriage return  Both methods are overloaded  A format string and parameters can be used  Text formatting  Numeric formatting
  • 11. Read and ReadLine Methods  Console.Read and Console.ReadLine read user input  Read reads the next character  ReadLine reads the entire input line
  • 12. Recommended Practices  Commenting Applications  Generating XML Documentation  Demonstration: Generating and Viewing XML Documentation  Exception Handling
  • 13. Commenting Applications  Comments are important  A well-commented application permits a developer to fully understand the structure of the application  Single-line comments  Multiple-line comments /* Find the higher root of the quadratic equation */ x = (…); // Get the user’s name Console.WriteLine("What is your name? "); name = Console.ReadLine( );
  • 14. Generating XML Documentation /// <summary> The Hello class prints a greeting /// on the screen /// </summary> class Hello { /// <remarks> We use console-based I/O. /// For more information about WriteLine, see /// <seealso cref="System.Console.WriteLine"/> /// </remarks> public static void Main( ) { Console.WriteLine("Hello, World"); } }
  • 15. Exception Handling using System; public class Hello { public static void Main(string[ ] args) { try{ Console.WriteLine(args[0]); } catch (Exception e) { Console.WriteLine("Exception at {0}", e.StackTrace); } } }
  • 16. Compiling, Running, and Debugging  Invoking the Compiler  Running the Application  Demonstration: Compiling and Running a C# Program  Debugging  Demonstration: Using the Visual Studio Debugger  The SDK Tools  Demonstration: Using ILDASM
  • 17. Invoking the Compiler  Common Compiler Switches  Compiling from the Command Line  Compiling from Visual Studio  Locating Errors
  • 18. Running the Application  Running from the Command Line  Type the name of the application  Running from Visual Studio  Click Start Without Debugging on the Debug menu
  • 19. Debugging  Exceptions and JIT Debugging  The Visual Studio Debugger  Setting breakpoints and watches  Stepping through code  Examining and modifying variables
  • 20. The SDK Tools  General Tools and Utilities  Windows Forms Design Tools and Utilities  Security Tools and Utilities  Configuration and Deployment Tools and Utilities
  • 21. Review  Structure of a C# Program  Basic Input/Output Operations  Recommended Practices  Compiling, Running, and Debugging