1 / 36

C # Introduction Part 1

C # Introduction Part 1. Which Visual Studio Should I use?. Any express (2010, 2012, 2013…) VS for Desktop Any full version. Which Visual Studio Should I use?. Any Express (2010, 2012, 2013…) VS for Desktop Any full version. .Net framework. Class Libraries … Console.ReadLine MSIL CLR.

azura
Télécharger la présentation

C # Introduction Part 1

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. C# Introduction Part 1

  2. Which Visual Studio Should I use? • Any express (2010, 2012, 2013…) VS for Desktop • Any full version

  3. Which Visual Studio Should I use? • Any Express (2010, 2012, 2013…) VS for Desktop • Any full version

  4. .Net framework • Class Libraries …Console.ReadLine • MSIL • CLR

  5. HelloWord, scope {}, method, Main, white space using System; usingSystem.Collections.Generic; usingSystem.Linq; usingSystem.Text; usingSystem.Threading.Tasks; namespace First { classProgram { staticvoid Main(string[] args) { Console.WriteLine("Hello World!"); Console.ReadLine(); } } }

  6. IDE, Projects, solutions, debug and release mode, … C:\Users\<yourname>\Documents\Visual Studio 2012\Projects .sln(open using Notepad -> it is xml) Look at using .csproj

  7. Debugging, Disable Squigglylines

  8. C# .NET languages Compiling C/C++ old languages code.cs code.vb code.cpp C# compiler VB.NET compiler Intermediate Language (MSIL) + metadata Assembly language compiling Common Language Runtime (CLR) JIT compiler Machine language .exe Machine language .exe

  9. Command Line compile and execution • C:\Windows\Microsoft.NET\Framework64\v4.0.30319 • csc.exe • cscProgram.cs

  10. Comments, IntelliSense // . . . /* . . . */

  11. Linenumbers (Tools->Options)

  12. Data Types, variables x = 2 y = x + 1; Console.WriteLine(y) … 3 Need Variables

  13. Data Types, variables cont

  14. C# Variables Declaration and Naming

  15. Primitives (though they are Objects)http://msdn.microsoft.com/en-us/library/ms228360(v=vs.90).aspx String object

  16. NullableType (a bit advance)

  17. King System.Object char int string

  18. Primitives are Objects

  19. isOperator* (will be later again) staticvoid Main(string[] args) { intmyInt = 5; TestIsOperator(myInt); stringmyString = "5"; TestIsOperator(myString); Console.ReadLine(); } privatestaticvoidTestIsOperator(Objectobj) { if (objisint) { inti = (int)obj; Console.WriteLine("Integer received"); } elseif (objisstring) { stringi = (string)obj; Console.WriteLine("String received"); } } }

  20. All are objects

  21. small integers (singed and unsinged)

  22. big integers (singed and unsinged)

  23. floatand double, decimal

  24. Special Floating numbers (Division by 0)

  25. Doubles vs Decimals

  26. Ex: float and decimal* (again later) using System; usingSystem.Collections.Generic; usingSystem.Linq; usingSystem.Text; namespaceDoubleVsDecimal { classProgram { staticvoid Main(string[] args) { double a = 0.2f; double b = 1.0f; Console.WriteLine("{0}", a - b); decimal c = 0.2m; decimal d = 1.0m; Console.WriteLine("{0}", c - d); Console.ReadLine(); } } }output: -0.799999997019768 -0.8

  27. Characters and Strings

  28. Strings methods* (again later)

  29. Immutable String * (again later)

  30. StringBuilder* (again later)

  31. Variable Scope *(again later) MyMethod

  32. Type Conversion (cast)

  33. Back to our example: using integer data type int x = 2; int y = x + 1; Console.WriteLine(y);

  34. Case sensitive language stringmyName; myName= "Andrew"; Console.WriteLine(myName); stringmyname = "Alice"; Console.WriteLine(myname); one line

  35. Introducing var • Don’t be afraid varmyName1 = "Bill";

  36. Conversion again* (again later). C# is a Strongly Typed Language string s = "Angie"; inttimes = 100; Console.WriteLine(times + s); string ok = times + s; intbad = times + s;

More Related