SlideShare a Scribd company logo
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# (20)

PDF
C sharp notes
Aravindharamanan S
 
PDF
overview of c#
Kandreo Gotro
 
PPT
Synapseindia dot net development
Synapseindiappsdevelopment
 
PPT
Visula C# Programming Lecture 2
Abou Bakr Ashraf
 
PPTX
C# Class Introduction
Arafat Bin Reza
 
PPTX
04. Console Input Output
Intro C# Book
 
PPT
Csharp_mahesh
Ananthu Mahesh
 
PPTX
CSharp Presentation
Vishwa Mohan
 
PPTX
A POWERPOINT PRESENTATION ABOUT INTRODUCTION TO C#
Jhay Deeh
 
PDF
C# 12 Pocket Reference: Instant Help for C# 12 Programmers Joseph Albahari
baskotluuis
 
PDF
C# c# for beginners crash course master c# programming fast and easy today
Afonso Macedo
 
PPTX
Csharp introduction
Sireesh K
 
PPTX
Introduction to C#
Raghuveer Guthikonda
 
PPT
ASP.NET Session 3
Sisir Ghosh
 
PPT
Lecture 1
Soran University
 
PDF
Learn C# programming - Program Structure & Basic Syntax
Eng Teong Cheah
 
PDF
Lesson 1 INTRODUCTION TO C# LANGUAGE.pdf
John Burca
 
PPTX
SPF Getting Started - Console Program
Hock Leng PUAH
 
PPTX
Getting Started - Console Program and Problem Solving
Hock Leng PUAH
 
PPTX
01. introduction to-programming
Stoian Kirov
 
C sharp notes
Aravindharamanan S
 
overview of c#
Kandreo Gotro
 
Synapseindia dot net development
Synapseindiappsdevelopment
 
Visula C# Programming Lecture 2
Abou Bakr Ashraf
 
C# Class Introduction
Arafat Bin Reza
 
04. Console Input Output
Intro C# Book
 
Csharp_mahesh
Ananthu Mahesh
 
CSharp Presentation
Vishwa Mohan
 
A POWERPOINT PRESENTATION ABOUT INTRODUCTION TO C#
Jhay Deeh
 
C# 12 Pocket Reference: Instant Help for C# 12 Programmers Joseph Albahari
baskotluuis
 
C# c# for beginners crash course master c# programming fast and easy today
Afonso Macedo
 
Csharp introduction
Sireesh K
 
Introduction to C#
Raghuveer Guthikonda
 
ASP.NET Session 3
Sisir Ghosh
 
Lecture 1
Soran University
 
Learn C# programming - Program Structure & Basic Syntax
Eng Teong Cheah
 
Lesson 1 INTRODUCTION TO C# LANGUAGE.pdf
John Burca
 
SPF Getting Started - Console Program
Hock Leng PUAH
 
Getting Started - Console Program and Problem Solving
Hock Leng PUAH
 
01. introduction to-programming
Stoian Kirov
 

More from Prem Kumar Badri (20)

PPTX
Module 15 attributes
Prem Kumar Badri
 
PPTX
Module 14 properties and indexers
Prem Kumar Badri
 
PPTX
Module 12 aggregation, namespaces, and advanced scope
Prem Kumar Badri
 
PPTX
Module 13 operators, delegates, and events
Prem Kumar Badri
 
PPTX
Module 11 : Inheritance
Prem Kumar Badri
 
PPTX
Module 10 : creating and destroying objects
Prem Kumar Badri
 
PPTX
Module 9 : using reference type variables
Prem Kumar Badri
 
PPTX
Module 8 : Implementing collections and generics
Prem Kumar Badri
 
PPTX
Module 7 : Arrays
Prem Kumar Badri
 
PPTX
Module 6 : Essentials of Object Oriented Programming
Prem Kumar Badri
 
PPTX
Module 5 : Statements & Exceptions
Prem Kumar Badri
 
PPTX
Module 4 : methods & parameters
Prem Kumar Badri
 
PPTX
Module 3 : using value type variables
Prem Kumar Badri
 
PPTX
Module 1 : Overview of the Microsoft .NET Platform
Prem Kumar Badri
 
PPTX
C# Non generics collection
Prem Kumar Badri
 
PPTX
C# Multi threading
Prem Kumar Badri
 
PPT
C# Method overloading
Prem Kumar Badri
 
PPTX
C# Inheritance
Prem Kumar Badri
 
PPTX
C# Generic collections
Prem Kumar Badri
 
PPTX
C# Global Assembly Cache
Prem Kumar Badri
 
Module 15 attributes
Prem Kumar Badri
 
Module 14 properties and indexers
Prem Kumar Badri
 
Module 12 aggregation, namespaces, and advanced scope
Prem Kumar Badri
 
Module 13 operators, delegates, and events
Prem Kumar Badri
 
Module 11 : Inheritance
Prem Kumar Badri
 
Module 10 : creating and destroying objects
Prem Kumar Badri
 
Module 9 : using reference type variables
Prem Kumar Badri
 
Module 8 : Implementing collections and generics
Prem Kumar Badri
 
Module 7 : Arrays
Prem Kumar Badri
 
Module 6 : Essentials of Object Oriented Programming
Prem Kumar Badri
 
Module 5 : Statements & Exceptions
Prem Kumar Badri
 
Module 4 : methods & parameters
Prem Kumar Badri
 
Module 3 : using value type variables
Prem Kumar Badri
 
Module 1 : Overview of the Microsoft .NET Platform
Prem Kumar Badri
 
C# Non generics collection
Prem Kumar Badri
 
C# Multi threading
Prem Kumar Badri
 
C# Method overloading
Prem Kumar Badri
 
C# Inheritance
Prem Kumar Badri
 
C# Generic collections
Prem Kumar Badri
 
C# Global Assembly Cache
Prem Kumar Badri
 
Ad

Recently uploaded (20)

PDF
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
PPTX
Neurodivergent Friendly Schools - Slides from training session
Pooky Knightsmith
 
PPTX
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
PDF
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
PDF
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
PDF
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PPTX
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
PPTX
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
PDF
Lesson 2 - WATER,pH, BUFFERS, AND ACID-BASE.pdf
marvinnbustamante1
 
PPTX
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PPTX
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
PPTX
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
PPTX
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
PPTX
How to Set Maximum Difference Odoo 18 POS
Celine George
 
PPTX
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
PDF
Dimensions of Societal Planning in Commonism
StefanMz
 
PPTX
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
PPTX
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
Neurodivergent Friendly Schools - Slides from training session
Pooky Knightsmith
 
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
Lesson 2 - WATER,pH, BUFFERS, AND ACID-BASE.pdf
marvinnbustamante1
 
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
How to Set Maximum Difference Odoo 18 POS
Celine George
 
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
Dimensions of Societal Planning in Commonism
StefanMz
 
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
Ad

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