Presentation is loading. Please wait.

Presentation is loading. Please wait.

C# Introduction Part 1. Which Visual Studio Should I use? Any Express (2012, 2013…) or Community Edition 2013 Any full version.

Similar presentations


Presentation on theme: "C# Introduction Part 1. Which Visual Studio Should I use? Any Express (2012, 2013…) or Community Edition 2013 Any full version."— Presentation transcript:

1 C# Introduction Part 1

2 Which Visual Studio Should I use? Any Express (2012, 2013…) or Community Edition 2013 Any full version

3 .Net framework Class Libraries … Console.ReadLine MSIL CLR

4 HelloWord, scope {}, method, Main, white space using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace First { class Program { static void Main(string[] args) { Console.WriteLine("Hello World!"); Console.ReadLine(); }

5 IDE, Projects, solutions, debug and release mode, … C:\Users\ \Documents\Visual Studio 2013\Projects - default Highly Recommend Use C:\Projects\MIS118. sln (open using Notepad -> it is xml ) Look at using. csproj

6 Debugging, Disable Squiggly lines

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

8 Command Line compile and execution C:\Windows\Microsoft.NET\Framework64\v4.0.30319 csc.exe csc Program.cs

9 Comments, Comments, IntelliSenseIntelliSense //... /*... */

10 Use Linenumbers (Tools->Options) Use Line numbers (Tools->Options)

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

12 Data Types, variables (cont)

13 C# Variables Declaration and Naming

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

15 NullableType (a bit advance) Nullable Type (a bit advance)

16 King System.Object char stringint

17 Primitives are Objects

18 is Operator* (will be later again) static void Main(string[] args) { int myInt = 5; TestIsOperator(myInt); string myString = "5"; TestIsOperator(myString); Console.ReadLine(); } private static void TestIsOperator(Object obj) { if (obj is int) { int i = (int)obj; Console.WriteLine("Integer received"); } else if (obj is string) { string i = (string)obj; Console.WriteLine("String received"); }

19 All are objects!!!

20 small int egers (singed and unsinged)

21 big int egers (singed and unsinged)

22 float and double, decimal

23 Special Floating numbers (Division by 0)

24 Doubles vs Decimals

25 Ex: float and decimal* (again later) using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace DoubleVsDecimal { class Program { static void 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 25

26 Characters and Strings

27 Strings methods* (again later)

28 Immutable String * (again later)

29 StringBuilder* (again later)

30 Variable Scope *(again later) MyMethod

31 Type Conversion (cast)

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

33 Case sensitive language string myName; myName = "Andrew"; Console.WriteLine(myName); string myname = "Alice"; Console.WriteLine(myname); one line

34 Introducing var Don’t be afraid var myName1 = "Bill";

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


Download ppt "C# Introduction Part 1. Which Visual Studio Should I use? Any Express (2012, 2013…) or Community Edition 2013 Any full version."

Similar presentations


Ads by Google