1 / 28

ITF11006 .NET

ITF11006 .NET. The Basics. The Basics. Data Types Value Types Reference Types Flow Control Conditional Loop Miscellaneous Enumerations Namespaces Class / Struct Data Members Functional Mem Base Classes System.Object System.String. Variables/Constants.

shamus
Download Presentation

ITF11006 .NET

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. ITF11006 .NET The Basics

  2. The Basics • Data Types • Value Types • Reference Types • Flow Control • Conditional • Loop • Miscellaneous • Enumerations • Namespaces • Class / Struct • Data Members • Functional Mem • Base Classes • System.Object • System.String

  3. Variables/Constants • Syntax[modifier] type identifier [= expression]; • Scope • Class/Block • Constants[modifier] const type identifier [= constant-expression]; • Type Inferencevar identifier [= expression];

  4. Predefined Data Types • Value Types • Reference Types

  5. Predefined Data Types • Value Types • Integer Types • Floating Point Types • Decimal Type • Boolean Type • Character Type

  6. Integer Types

  7. Floating Point

  8. Decimal Type

  9. Boolean Type

  10. Character Type

  11. Nullable Types (http://msdn.microsoft.com/en-us/library/1t3y8s4s(v=VS.100).aspx) • T? orSystem.Nullable(Of T) • Ordinary type plus null

  12. Predefined Reference Types • Object • String

  13. Flow Control • Conditional • if • switch • Loop • for • while • do..while • foreach • Jump • goto • break • continue • return

  14. Conditional Statements • if if (expression) statement1 [else statement2] • switchswitch (expression) { case constant-expression: statement jump-statement [default: statement jump-statement] }

  15. Loops • forfor ([initializers]; [expression]; [iterators]) statement • whilewhile (expression) statement • do..whiledo statement while (expression); • foreachforeach (typeidentifier in expression) statement

  16. Jump Statements • goto • break • continue • return • (throw)

  17. Enumerations • enum[modifiers] enum identifier [:base-type]{enumerator-list} • Inherits from System.Enum • Flags Attribute • Use enumerations

  18. Namespaces • Logical grouping of functionality • <company>.<technology/sw package> • Using directive

  19. Class (/Struct) • Data Members • Fields • Constants • Events • Function Members • Methods • Properties • Constructor • Destructor • Operators • Indexers

  20. Methods • syntax[modifiers] return-type method-name([formal-parameter-list]) { statement(s)} • Named Argumentsstring FullName(string firstName, string lastName)…FullName(“Ole”, “Olsen”);FullName(lastName: “Olsen”, firstName: “Ole”); • Optional Arguments • Method Overloading

  21. Properties • syntax[modifiers] type identifier{ set {accessor-body} get {accessor-body} } • Auto-Implementedpublic string Age(get; private set;) • Choosing Between Properties and Methods http://msdn.microsoft.com/en-us/library/ms229054.aspx

  22. Construction and Disposal • Constructors • Instance • Class • Calling • Destructor • Why • How (pattern) • Dispose vs. Close

  23. Operators • Operator Overloading public static Vector operator * (double lhs, Vector rhs) { return new Vector(lhs * rhs.x, lhs * rhs.y, lhs * rhs.z); } public static Vector operator * (Vector lhs, double rhs) { return rhs * lhs; } Console.WriteLine("vect2 * 2 = " + ( vect2 * 2).ToString());

  24. Indexers public char this[int index] { get { ... } set { ... } }

  25. Instance vs. Class Level • Static • this vs. class name

  26. Struct • No inheritance (almost) • Constructors • Fields are sometimes declared public! • Structs are value types

  27. Struct vs. class • Footprint • Performance

  28. object (System.Object) • Methods • Comparing for Equality • Reference Types • Value Types

More Related