Csharp_Ch3_PPT - C 2010 for Programmers Chapter 3 Dr...

Info iconThis preview shows pages 1–11. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: C# 2010 for Programmers Chapter 3 Dr. Meng-Hung Wu Chapter 3 Topics Chapter 3 discusses the following main topics: • The Parts of a C# Program • The Write and WriteLine Methods, and the .NET Framework • Variables and Literals • C# Data Types • Arithmetic Operators • Combined Assignment Operators • Conversion Between Primitive Data Types Chapter Topics Chapter 3 discusses the following main topics: • Creating Named Constants with const • The string Type • Scope • Comments • Programming Style • Reading Keyboard Input Parts of a C# Program • A C# source code file contains one or more C# classes. • If more than one class is in a source code file, only one of them may be public. • The public class and the filename of the source code file must match. ex: A class named Simple must be in a file named Simple.cs • Each C# class can be separated into parts. Parts of a C# Program • Example: Simple.cs • To compile the example: • csc Simple.cs • Notice the .C# file extension is needed. • To run the example: • Simple • Notice there is no file extension here. public class Simple { } This area is the body of the class Simple. All of the data and methods for this class will be between these curly braces. Analyzing The Example // This is a simple C# program. This is a C# comment. It is ignored by the compiler. This is the class header for the class Simple This is the namespace for the class Simple using System; Analyzing The Example // This is a simple C# program. using System; public class Simple { } public static void Main() { } This area is the body of the main method. All of the actions to be completed during the main method will be between these curly braces. This is the method header for the main method. The main method is where a C# application begins. Analyzing The Example // This is a simple C# program. using System; public class Simple { } public static void Main() { Console.WriteLine("Programming is great fun!"); } This is the C# Statement that is executed when the program runs. Parts of a C# Program • Comments • The line is ignored by the compiler. • The comment in the example is a single-line comment. • Namespace • A namespace contains classes. • The System namespace contains the basic classes need for all C# programs • The using keyword allows use the various class methods without having to use the namespace qualifier each time. Parts of a C# Program • Class Header • The class header tells the compiler things about the class such as what other classes can use it ( public ) and that it is a C# class ( class ), and the name of that class ( Simple ). • Curly Braces • When associated with the class header, they define the scope of the class....
View Full Document

Page1 / 84

Csharp_Ch3_PPT - C 2010 for Programmers Chapter 3 Dr...

This preview shows document pages 1 - 11. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online