Docsity

C# Programming: Understanding Different Types of Applications and Elements, Slides of Advanced Computer Programming

Partial preview of the text

Download C# Programming: Understanding Different Types of Applications and Elements and more Slides Advanced Computer Programming in PDF only on Docsity!

Part II

Types of Applications Developed

with C#

  • Web applications
  • Windows graphical user interface (GUI) applications
  • Console-based applications
  • Class libraries and stand-alone components (.dlls), smart device applications, and services can also be created

Web Applications (continued)

  • C# was designed with the Internet applications in mind
  • Can quickly build applications that run on the Web with C# - Using Web Forms: part of ASP.NET

Windows Applications

  • Applications designed for the desktop
  • Designed for a single platform
  • Use classes from System.Windows.Form
  • Applications can include menus, pictures, drop-down controls, buttons, text boxes, and labels
  • Use drag-and-drop feature of Visual Studio

Console Applications

  • Normally send requests to the operating system
  • Display text on the command console
  • Easiest to create
    • Simplest approach to learning software development
    • Minimal overhead for input and output of data

Exploring the First C# Program

line 1 // This is traditionally the first program written. line 2 using System; line 3 namespace HelloWorldProgram line 4 { line 5 class HelloWorld line 6 { line 7 static void Main( ) line 8 { line 9 Console.WriteLine(“Hello World!”); line 10 } line 11 } line 12 }

Comments in green Keywords in blue

From Example 1-

Elements of a C# Program

  • Comments
    • line 1 // This is traditionally the first program written.
    • Like making a note to yourself or readers of your program
    • Not considered instructions to the computer
    • Not checked for rule violations
    • Document what the program statements are doing

Comments

  • Make the code more readable
  • Three types of commenting syntax
    • Inline comments
    • Multiline comments
    • XML documentation comments

Multiline Comment

  • Forward slash followed by an asterisk (/*) marks the beginning
  • Opposite pattern (*/) marks the end
  • Also called block comments /* This is the beginning of a block multiline comment. It can go on for several lines or just be on a single line. No additional symbols are needed after the beginning two characters. Notice there is no space placed between the two characters. To end the comment, use the following symbols. */

XML Documentation Comments

  • Extensible Markup Language (XML)
    • Markup language that provides a format for describing data using tags
    • Similar to HTML tags
  • Three forward slashes (///) mark beginning
  • Advanced documentation technique used for XML-style comments
  • Compiler generates XML documentation from them

Namespace

  • Namespaces provide scope for the names defined within the group - Captain example
  • Groups semantically related types under a single umbrella
  • System: most important and frequently used namespace
  • Can define your own namespace
    • Each namespace enclosed in curly braces: { }

Namespace (continued)

From Example 1-

line 1 // This is traditionally the first program written. line 2 using System; line 3 namespace HelloWorldProgram line 4 {

line 12 }

Predefined namespace (System) – part of .NET FCL

User-defined namespace Body of user- defined namespace

Class Definition (continued)

line 1 // This is traditionally the first program written. line 2 using System; line 3 namespace HelloWorldProgram line 4 { line 5 class HelloWorld line 6 {

line 11 } line 12 }

User- defined class

Class Definition (continued)

  • Define class members within curly braces
    • Include data members
      • Stores values associated with the state of the class
    • Include method members
      • Performs some behavior of the class
  • Can call predefined classes’ methods
    • Main( )