Presentation is loading. Please wait.

Presentation is loading. Please wait.

Microsoft .NET Framework 4.0. Fundamentals

Similar presentations


Presentation on theme: "Microsoft .NET Framework 4.0. Fundamentals"— Presentation transcript:

1 Microsoft .NET Framework 4.0. Fundamentals
Madina Tulegenovna Ipalakova

2 Major Objectives of the Course
Developing applications that use system types and collections Implementing service processes, threading, and application domains in a .NET Framework application Implementing serialization and input/output functionality in a .NET Framework application Implementing globalization, drawing, and text manipulation functionality in a .NET Framework application Embedding configuration, diagnostic, management, and installation features into a .NET Framework application

3 The .NET Framework and C# Lecture 1
M.T. Ipalakova

4 .NET Framework was publicly announced in June 2000
unified the existing Windows interfaces and services under a single application programming interface (API) added many industry standards, such as Simple Object Access Protocol (SOAP) added many existing Microsoft technologies, such as the Microsoft Component Object Model (COM and COM+) and Active Server Pages (ASP) enabled developers to focus on the application logic rather than more common programming tasks includes one of the largest available class libraries continues to evolve by supporting new technologies and industry standards, providing even more classes

5 .NET Framework The .NET Framework is designed to do the following:
Provide a runtime environment that simplifies software deployment and reduces the chances of version conflicts Enable the safe execution of code Use industry standards for all communication to enable integration with non-.NET code Provide a consistent developer experience across all types of applications in a way that is language- and platform- independent Provide a runtime environment that minimizes or eliminates the performance problems of scripted or interpreted languages

6 Four Components of the .NET Framework
Common Language Runtime – CLR Class Library Parallel Computing Platform Dynamic Language Runtime

7 1. Common Language Runtime – CLR
CLR is the core of the .NET Framework provides a unified type system (common type system – CTS) a common intermediate language (CIL) a managed runtime environment (virtual execution system – VES) developing and executing language- and platform- independent applications eliminating, or reducing many common programming errors

8 Common Type System – CTS
the unified type system enables all .NET languages to share the same type definitions, enabling those types to be manipulated in a consistent manner provides a minimum set of rules a .NET language (and its compiler) must follow, called the common language specification (CLS) enables the idea of language integration

9 Common Intermediate Language – CIL
managed code is partially compiled into a low-level language called common intermediate language (CIL) is like assembly language is made up of individual, low-level instructions that represent your code An assembly is a partially compiled unit, or package, that contains CIL instructions and provides a logical boundary for defining types

10 Virtual Execution System
handles the low-level core services your application needs. Just as Java applications require the Java virtual machine (JVM) to run, a managed application requires the CLR, and more specifically the VES, to run is responsible for actually loading the CIL code, executing that code and, ultimately, managing the memory allocations required by the application provides is the Just-In-Time (JIT) compiler Just-In-Time compilation is the process of taking the partially compiled CIL code and generating executable object code, or native code, at runtime

11 2. Framework Class Library – FCL
FCL is a rich set of reusable types enabling you to achieve a high level of developer productivity by simplifying many common programming tasks

12 2. Framework Class Library (cont.)
Base Class Libraries (BCL) provide types that represent the intrinsic CLR types, collections, streams, string manipulation, basic file access, and a variety of other operations or data structures The remaining classes provide data access, XML support, globalization support, diagnostics, configuration, networking, communication, business workflow support, web applications, and Windows desktop applications, etc.

13 Namespaces A namespace is simply a collection of types (classes) and has no effect on the accessibility of a type Namespaces can be split across multiple assemblies The .NET Framework uses the hierarchical nature of namespaces Namespace Description System The base, or root, namespace for .NET; contains classes that define the commonly used data types, exceptions, and events System.Collections.Generic Contains classes that define various generic collections, enabling you to create strongly typed collections System.IO Contains classes that enable synchronous and asynchronous reading and writing on data streams and files System.Linq Contains classes and interfaces that support queries using Language-Integrated Query (LINQ) System.Text Contains classes for working with strings and characters

14 3. Parallel Computing Platform
Contains diagnostic tools which provides support for parallel programming Enables you to write efficient and scalable code that takes advantage of multiple processors in a natural and simple way

15 4. Dynamic Language Runtime
is built on top of the common language runtime CLR provides language services for dynamic languages such as IronRuby and IronPython gives you the flexibility to choose the most appropriate language to solve a specific business need enables non-dynamic languages such as C# to support a consistent and simple syntax for working with dynamic objects whether the source is COM, IronRuby, Iron- Python, or JavaScript

16 The C# Language was developed with the .NET Framework by Anders Hejlsberg, Scott Wiltamuth, and Peter Golde was first available in July 2000 have been written specifically for the .NET Framework is considered by many to be the canonical language of the .NET Framework drew inspiration for its syntax and primary features from Delphi 5, C++, and Java 2

17 The C# Language is an object-oriented language and fully supports the inheritance, polymorphism, encapsulation, and abstraction supports component-oriented programming has the feature of Garbage collection which automatically manages memory provides Exception handling to detect and recover from errors is a type-safe language (it impossible to have uninitialized variables, illegally access memory, or store data of one type in a location that can accept only a different type)

18 Types Types are divided into two main categories:
Value Types which are completely self-contained and copied “by value.” Variables of a value type directly contain their data and are stored in a stack (built-in types, user-defined types, enumerations) Reference types store the address of their data, also known as a pointer, on the stack. The actual data to which that address refers is stored in an area of memory called the heap (classes, arrays, interfaces, delegates)

19 Predefined Types Keyword Description Range bool Logical Boolean
true or false byte Unsigned 8-bit integer 0 to 255 char A single 16-bit Unicode character U+0000 to U+FFFF decimal A 128-bit data type with 28–29 significant digits (–7.9 x 1028 to 7.9 x 1028) / (100 to 28) double Double-precision 64-bit floating point up to 15–16 digits ±5.0 x 10–324 to ±1.7 x 10308 float Single-precision 32-bit floating point up to 7 digits ±1.5 x 10–45 to ±3.4 x 1038 int Signed 32-bit integer –231 to 231 – 1

20 Predefined Types Keyword Description Range long Signed 64-bit integer
–263 to 263 – 1 sbyte Signed 8-bit integer –128 to 127 short Signed 16-bit integer –32,768 to 32,767 unit Unsigned 32-bit integer 0 to 4,294,967,295 ulong Unsigned 64-bit integer 0 to 18,446,744,073,709,551,615 ushort Unsigned 16-bit integer 0 to 65,535 object Base type of all other value and reference types, except interfaces N/A string A sequence of Unicode characters

21 Special Types void type indicates the absence of a type
dynamic type is similar to object, with the primary difference being all operations on that type will be resolved at runtime rather than compile time var represents an implicitly typed variable and tells the compiler to determine the real type based on the assigned data int i = 10; string s = "This is a test"; double d = 20.3;

22 Statements and Expressions
A statement is simply a single, complete program instruction that must end with a semicolon (;) A statement block, which is simply a group of statements enclosed by braces An expression evaluates to a value. A statement to be a program action, an expression is a computation Expressions that result in a Boolean value (either true or false) are used to test if one or more conditions are true and are called Boolean expressions

23 Identifiers An identifier is a name for a variable, field, or constant. It must follow these rules: Only letters (uppercase and lowercase), digits, and the underscore character are valid Must begin with a letter or the underscore character Must be unique within a given declaration space Identifiers are case-sensitive Some additional guidelines that should be followed when choosing identifiers are Identifiers should be easily readable Identifiers should not use abbreviations or contractions as part of the name Identifiers should convey the meaning or intent as much as possible

24 Arithmetic Operators (+) – addition (–) – subtraction
(*) – multiplication (/) – division (when dividing one integer by another, the result is an integer; any remainder is discarded, and the result is rounded toward zero (%) – obtaining the remainder of an integer division (+=,–=, *=, /=) – compound assignment operators (++) – increment operator (––) – decrement operator

25 Greater than or equal to
Relational Operators Operator Symbol Greater than > Less than < Greater than or equal to >= Less than or equal to <= Exactly equal to == Not equal to !=

26 Boolean Operators Operator Symbol AND && OR || NOT !
Evaluate Boolean expressions that result in either true or false Operator Symbol AND && OR || NOT !

27 Control Flow Statements
Selection Statements (if-else, switch) Iteration (Looping) Statements (while, do-while, for) Jump Statements (break, continue, return)

28 If-Else Statement if ( boolean-expression ) embedded-statement
consequence-statement else alternative-statement

29 if (isRaining) canPlay = false;
If-Else Statement Examples if (isRaining) canPlay = false; if (order > 50.00) { freeShipping = true; } else { freeShipping = false; }

30 if ((isStudent) && (age <= 24)) {
If-Else Statement Examples if ((isStudent) && (age <= 24)) { discount = order_price * 0.1; }else if (order_price > 50.00) { discount = shipping; }else { discount = 0; }

31 if ((isStudent) && (age <= 24)) { discount = discount +
If-Else Statement Examples if ((isStudent) && (age <= 24)) { discount = discount + order_price * 0.1; if (order_price > 50.00) { discount = discount + shipping; }

32 Nested If-Else Statement
Examples if ((isStudent) && (age <= 24)) { if (order_price <= ) { discount = order_price * 0.1; } else if (order_price > ) { discount = order_price * 0.15; } else if (order_price > 50.00) { discount = discount + shipping; }

33 Switch Statement The switch statement selects a statement list based on a label that corresponds to the value of the expression The syntax of a switch statement is switch ( expression ) { case constant-expression : statement-list break; default : }

34 Switch Statement Example int x = 4; switch (x) { case 0:
Console.WriteLine(“x = “ + x); break; case 1: default: Console.WriteLine(“Invalid”); }

35 Switch Statement Example int x = 4; switch (x) { case 0: case 1:
Console.WriteLine(“x = “ + x); break; default: Console.WriteLine(“Invalid”); }

36 While Statement A while statement is a top-tested loop that repeatedly executes an embedded statement until the boolean- expression evaluates to false while ( boolean-expression ) embedded-statement int i = 1;  while (i < 5) { Console.WriteLine("i = " + i);     i = i + 1; }

37 Do-While Statement A do-while statement also repeatedly executes an embedded statement until the booleanexpression evaluates to false. Unlike the while statement, a do statement is a bottom-tested loop do embedded-statement while ( boolean-expression ); int i = 1;  do { Console.WriteLine("i = " + i);      i = i + 1; } while (i < 5)

38 For Statement It repeatedly executes an embedded statement until a specified expression evaluates to false for ( initializer ; condition ; iterator ) embedded-statement for(int i = 0; i < 3; i++) { Console.WriteLine(i); }

39 Foreach Statement The foreach statement executes a statement for each element in an array or collection foreach ( type identifier in expression ) embedded-statement string s = “This is a test.”; foreach (char c in s) { Console.WriteLine(c); }

40 Break Statement The break statement is used to exit the nearest switch, while, do, for, or foreach statement. If multiple statements are nested within each other, only the innermost statement is exited for (int i = 0; i < 10; i++) { Console.WriteLine(i); if (i == 3) break; }

41 Continue Statement The continue statement starts a new iteration of the nearest while, do, for, or foreach statement. If multiple statements are nested within each other, the continue statement applies only to the innermost statement. Any statements between continue and the end of the loop body are skipped for (int i = 0; i < 10; i++) { if (i < 3) continue; } Console.WriteLine(i);

42 Return Statement The return statement causes control to return to the caller of the member containing the return statement


Download ppt "Microsoft .NET Framework 4.0. Fundamentals"

Similar presentations


Ads by Google