1 / 19

ECE 264 Class 1-2

ECE 264 Class 1-2. P. Viall Fall 2014. What is .NET?. platform for developing applications NOT Microsoft specific (but designed by Microsoft Versions run on Linix (Max), iPhone , and Android In theory, multiple languages may be used C# made up of the best components of C++ and Java.

Télécharger la présentation

ECE 264 Class 1-2

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. ECE 264 Class 1-2 P. Viall Fall 2014

  2. What is .NET? • platform for developing applications • NOT Microsoft specific (but designed by Microsoft • Versions run on Linix (Max), iPhone, and Android • In theory, multiple languages may be used • C# made up of the best components of C++ and Java

  3. What is the .NET framework? • giant library of code (for your use) • CLR – Common Language Runtime • CTS – Common Type System (basic data types)

  4. How are applications compiled? Step 1 “Assembly” (Non-OS/non-machine specific code) Compilaiton to CIL (Common Intermediate Language) C# Program Step 2 “Assembly” (Non-OS/non-machine specific code) Native Code (Machine and OS specific executable) JIT (Just In Time) Compiler

  5. About Managed Code System Runtime .NET CLR (Common Language Runtime) Native Code Native Code Native Code C# is (by default) MANAGED CODE...that is the CLR checks each operation to insure it will not overwrite anything it shouldn’t (array bounds, system space, etc.). It is possible to mark code as “unsafe” and allow it to do anything.

  6. What can you do with C# • Console applications (dos box) • Desktop (windows) applications with menus, dialog boxes, buttons, etc. • Windows Store applications – designed for touch devices • Web applications – anything viewed through a web browser • WCF (Windows Communication Foundation) for use in distributed (networked) applications

  7. Variables and Expressions

  8. Variables and Expressions

  9. Naming of variables • Same as C except variables may start with @ • Naming convention is either PascalCase or camelCase • PascalCasecapitolized the first letter of each word (used for name spaces and object types) • camelCase is the same except first word is not capitolized. (used for variables)

  10. Literal values

  11. Arithmetic Operations & Namespaces • Same as C ( +, -, *, /, %, ++, --, =, +=, -=, *=, /=, %=) • Precedence is same as C • Namespaces are a way to compartmentalize scope of variables (similar to how functions compartmentalize). HOWEVER, you can access a variable in a different namespace by specifying the entire name (namespace.variablename). If namespaces are nested (one inside the other), you need to specify both namespaces and variable name (namespace1.namespace2.variablename)

  12. Logic & flowcontrol

  13. &, |, !, ^ with bool values • & = logical and • | = logical or • ! = logical not • ^ = logical xor • &=, |=, ^= are also allowed

  14. &, |, ~, ^ with integer values • Are bitwise instructions...each individual pair of bits in the integer are evaluated separately • & = bitwise and • | = bitwise or • ~ = bitwise not (compliment) • ^ = bitwise xor • &=, |=, ^= are also allowed

  15. bitwise example intmyColor = 0; boolcontainsRed; myColor = myColor | 2; // add green myColor = myColor | 4; // add red myColor = myColor & (~2); // remove green containsRed = (myColor & 4) == 4;

  16. bitshift operators (<<,>>,>>=,<<=)

  17. Operator Precidence Chart

  18. More statements Ternary Operator <test> ? <result if true> : <result if false> Example: big = (a>b)?a:b; if ( ) – same as C if () else – same as C do { } while (condition) – same as C while { } – same as C for ( ) { } – same a C break, continue – same as C

  19. switch – almost like C except static void Main(string[] args) { const string myName = “kirk"; const string uncommonName= “sherajeseb"; const string sillyName = “miles"; string name; Console.WriteLine("What is your name? "); name = Console.ReadLine(); switch (name.ToLower()) { case myName: Console.WriteLine("You have the same name as me"); break; case sexyName: Console.WriteLine(“What an uncommon name!"); break; case sillyName: Console.WriteLine("That's a silly name."); break; } Console.WriteLine("Hello {0}!", name); Console.ReadKey(); }

More Related