Presentation is loading. Please wait.

Presentation is loading. Please wait.

C# and the .NET Framework

Similar presentations


Presentation on theme: "C# and the .NET Framework"— Presentation transcript:

1 C# and the .NET Framework
An Introduction to C#

2 Introduction to Computing
Processors have different instruction sets with low-level simple instructions High-level languages – more expressive, closer to software design Compilers translate from one language to another Interpreters execute code

3 Translating a high-level program
Processor ABC program (executable) Compiler Translating a high-level program

4 The .NET Framework Two main parts
Common Language Runtime (CLR) manages execution of code and provides services .NET Framework Class Library provides a large and very useful set of types

5 The Common Language Runtime
Common Type System defines the types of data that manages code can use. Common Language Specification (CLS) defines features that every language for developing managed code must provide Each language code compiles to MSIL, Microsoft Intermediate Language. Compiles to native code at runtime.

6 The .NET Framework Class Library
Groups types into namespaces. Contains about 100 namespaces. For example, System -- Contains fundamental types. System.Drawing -- Provides graphics. System.Windows.Forms -- For user interfaces in Windows-based applications

7 C# Features Object-oriented – used for business objects or system applications – internet applications Goals include productivity and safety power, expressiveness, and flexibility Combines rapid application development of Visual Basic with power of C++

8 How C# works Compiler translates C# source to MSIL code for a virtual machine, similar to a hardware processor During runtime the CLR use a Just-In-Time (JIT) compiler to translate the MSIL code to the instruction set of the processor

9 Compiling and executing a Java program
JIT1 C#Source Code MSIL code Processor 1 code Compiler JIT2 Processor 2 code Compiling and executing a Java program

10 public class Square { static void Main() { int number = 345; // '=' denotes assignment int squared = number * number; // '*' denotes multiplication System.Console.WriteLine ("The square of {0} is {1}", number, squared); }

11 The output of Example 1 The square of 345 is 119025
System namespace, Console class, WriteLine method "The square of {0} is {1}" is a pattern The value of number substitutes for {0} The value of squared substitutes for {1}

12 Lexical Structure Rules for dividing program text into a sequence of elements Whitespace -- spaces, tabs, carriage returns Comment – for human readers only Punctuators ( ) { } [ ] ; , . : Operators * / and so on Literals – specific values such as 345 Identifiers – the names used for program entities Keywords – reserved names for special uses

13 C# compiler lexical analyzer
int number = 345; C# compiler lexical analyzer keyword identifier operator literal punctuator (int) (number) (=) (345) (;) (whitespace and comment discarded) Lexical analysis of a single line of Example 1

14 Syntax Grammatical rules for combining lexical elements into programs
Declaration – defines a part of a program Statements – controls execution sequence Expressions – compute values

15 The overall syntactic structure of Example 1.1
class declaration method declaration statement statement statement The overall syntactic structure of Example 1.1

16 The Steps of Software Development
Identifying the requirements of the system. Designing a system that meets the requirements. Implementing the system. Testing that the system operates correctly and meets the requirements. Making improvements as needed.


Download ppt "C# and the .NET Framework"

Similar presentations


Ads by Google