1 / 41

Session 01

Session 01. Module 1: Introduction to C# Module 2: Variables and Data Types. Module1 - Objectives. Describe the .NET Framework List the other components of .NET Framework Explain CLR and MSIL Define Memory Management and Garbage Collection

amara
Télécharger la présentation

Session 01

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Session 01 Module 1: Introduction to C# Module 2: Variables and Data Types

  2. Module1 - Objectives • Describe the .NET Framework • List the other components of .NET Framework • Explain CLR and MSIL • Define Memory Management and Garbage Collection • Describe the Microsoft Visual Studio 2005 product • Learn the key elements of Visual Studio 2005 IDE • List the basic features of C# Introduction & Variables & Data types / Session 1 / 2 of 41

  3. Architecture of .Net Framework(1) • The .Net Framework is a multi-lingual environment to build, deploy and run applications • It enables programmers to develop applications for various platform such as mobile devices, desktop computer, smartphones and so on. Introduction & Variables & Data types / Session 1 / 3 of 41

  4. Architecture of .Net Framework(2) • The .Net Framework architecture comprises of following: • Languages included in the .Net Framework • .Net Framework class library (FCL) • The Common Language Runtime(CLR) Introduction & Variables & Data types / Session 1 / 4 of 41

  5. Architecture of .Net Framework(3) • Other importance components in .Net Framework • Web Forms • Web services • Windows Forms • ASP.NET • ADO.NET • XML Classes • Base Framework Classes • Common Language Specification • Common Type System Introduction & Variables & Data types / Session 1 / 5 of 41

  6. Microsoft Intermediate Language(MSIL) • When code written in .Net Framework language such as C#,VB…is complied, output code is in the form of Microsoft Intermediate Language(MSIL) Introduction & Variables & Data types / Session 1 / 6 of 41

  7. Common Language Runtime(CLR) • When a code is executed for first time, the MSIL code is converted to a code native to operating system. • This is done ar runtime by the Just-in-Time(JIT) compiler present in CLR. Introduction & Variables & Data types / Session 1 / 7 of 41

  8. Basic Features of C# • Object-oriented programming language • Type safety checking • Garbage collection • Standarbisation by ECMA(European Computer Manufacturers Association) • Generic Types and Methods Introduction & Variables & Data types / Session 1 / 8 of 41

  9. Visual Studio 2005(1) • Visual studio 2005 is complete set of development tools to build desktop applications, web application, XML web service and mobile applications. • Primary advantages are: • Development of applications for .Net Framework 2.0 • Development of applications for handheld devices using .Net Compact Framework 2.0 Introduction & Variables & Data types / Session 1 / 9 of 41

  10. Visual Studio 2005(2) Introduction & Variables & Data types / Session 1 / 10 of 41

  11. Key elements of VS 2005 • Solution Explorer • Code Editor • Properties Window • Dynamic help Introduction & Variables & Data types / Session 1 / 11 of 41

  12. Write and run first console application • Step 1: Create new project Introduction & Variables & Data types / Session 1 / 12 of 41

  13. Write and run first console application • Step 2:Compile program • You can compile console application from command line or use IDE • If compile program from command line: • Edit PATH variable, add following line in PATH C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727; • in command line window, change to directory of program and type: csc <fileName.cs> • If use IDE, press F6 to compile program Introduction & Variables & Data types / Session 1 / 13 of 41

  14. Write and run first console application • Step 3: Run program • If use command line window, type .exe file name • If use IDE, press Ctrl + F5 Introduction & Variables & Data types / Session 1 / 14 of 41

  15. Module 1 – Summary (1) • .Net Framework is multi-language platform to build, deploy and run various types of applications • Two major components of .Net Framework is CLR and FCL • When code is written in .Net language such as C#,VB…compiled, output code is converted to code native to operating system by Just-In-Time language Introduction & Variables & Data types / Session 1 / 15 of 41

  16. Module 1 – Summary (2) • C# is an object-oriented programming language derived from c and C++. • C# support features like type-safety checking, garbage collection, ECMA standardization, generics • Visual studio 2005 is complete set of tool to build high performance applications Introduction & Variables & Data types / Session 1 / 16 of 41

  17. Module 2 - Objectives Identify basic data types in C# Explain XML source code documentation List the keywords in C# Describe reference data types Constants and Literals Describe console output methods in C# Explain number and datetime format specifiers Introduction & Variables & Data types / Session 1 / 17 of 41

  18. Variables • A variable is an entity whose value can keep changing • Declaration syntax: <datatype> <variableName> [,variableName=<value>]; • Assignment syntax: <variable> = <value>; Introduction & Variables & Data types / Session 1 / 18 of 41

  19. Data Types (1) In C#, data types are also divided into two categories: Value types: Can be either the built-in data type or a user-defined data type. Stack storage results in faster memory allocation to variables of value types Reference types: Variables of reference type store the memory address of other variables in a heap. Most of user-defined data types such as class are reference types. Introduction & Variables & Data types / Session 1 / 19 of 41

  20. Data Types (2) Introduction & Variables & Data types / Session 1 / 20 of 41

  21. Predefined Data Types (1) • The predefined data types are referred to as basic data types in C#. • These data types have a predefined range and size. • The size of the data type helps the compiler to allocate memory space and ensure the value assigned is within the range of the data type. Introduction & Variables & Data types / Session 1 / 21 of 41

  22. Predefined Data Types (2) Introduction & Variables & Data types / Session 1 / 22 of 41

  23. Reference Data Type Classification Reference types can be classified as Introduction & Variables & Data types / Session 1 / 23 of 41

  24. Some Reference Data Types Introduction & Variables & Data types / Session 1 / 24 of 41

  25. Variable Naming Rules Introduction & Variables & Data types / Session 1 / 25 of 41

  26. Comments Comments are given by programmer to provide information about a piece of code. Comments make the program more readable. Comments help the programmer to explain the purpose of using a particular variable, method, class, or code snippet. Comments are ignored by the compiler during the execution of the program. C# supports three types of comments: Single-line comments Multiple-line comments XML comments Introduction & Variables & Data types / Session 1 / 26 of 41

  27. XML Documentation In C#, we can create an XML document that will contain all the XML comments. This document is useful when multiple programmers want to view information of the program. To create an XML document, we must use the VS 2005 command prompt window. csc /doc:<XMLfilename.xml> <CSharpfilename.cs> Introduction & Variables & Data types / Session 1 / 27 of 41

  28. Predefined XML Tags XML comments are inserted in XML tags. These tags can either be predefined or user-defined. XML comments begin with three forward slashes (///) Introduction & Variables & Data types / Session 1 / 28 of 41

  29. Constants Constants are fixed values assigned to identifiers that are not modified throughout the execution of the code. We have to initialize a constant at the time of its declaration. The compiler can identify constants at the time of compilation because of the const keyword. Introduction & Variables & Data types / Session 1 / 29 of 41

  30. Literals A literal is a static value assigned to variables and constants In C#, there are six types of literals Introduction & Variables & Data types / Session 1 / 30 of 41

  31. Keywords Keywords are reserved words and are separately compiled by the compiler. They convey a predefined meaning to the compiler and hence cannot be created or modified. Introduction & Variables & Data types / Session 1 / 31 of 41

  32. Escape sequence characters in C# Introduction & Variables & Data types / Session 1 / 32 of 41

  33. Console Input/Output Operations Two output methods: Console.Write() and Console.WriteLine() These two methods accept parameters for formatting the text before the output is displayed Console.Write(“Customer name: {0}”, custName); Console.WriteLine(“Total amount: ${0:#,###.#0}”, totalAmount); Two input methods: Console.Read() and Console.ReadLine() custName = Console.ReadLine(); Introduction & Variables & Data types / Session 1 / 33 of 41

  34. Convert Methods The ReadLine() method can also be used to accept integer values. The data is accepted as string and then converted into other data type by a Convert class age = Convert.ToInt32(Console.ReadLine()); Introduction & Variables & Data types / Session 1 / 34 of 41

  35. Format Specifiers Format specifiers are special characters that are used to display values of variables in a formatted manner. Some type of format specifiers Number Format Specifiers Datetime Format Specifiers Introduction & Variables & Data types / Session 1 / 35 of 41

  36. Number Format Specifiers We can convert numeric values in different formats. Introduction & Variables & Data types / Session 1 / 36 of 41

  37. More Number Format Specifiers Introduction & Variables & Data types / Session 1 / 37 of 41

  38. Datetime Format Specifiers Introduction & Variables & Data types / Session 1 / 38 of 41

  39. More Datetime Format Specifiers Introduction & Variables & Data types / Session 1 / 39 of 41

  40. Module 2 – Summary (1) In C#, data types are also divided into two categories: value types and reference types The predefined data types are referred to as basic data types in C#. C# supports three types of comments XML comments are inserted in XML tags. These tags can either be predefined or user-defined. Introduction & Variables & Data types / Session 1 / 40 of 41

  41. Module 2 – Summary (2) Two output methods: Console.Write() and Console.WriteLine() Two input methods: Console.Read() and Console.ReadLine() Convert class is used to convert a variable into another data type. Some type of format specifiers: number and datatime Introduction & Variables & Data types / Session 1 / 41 of 41

More Related