c# introduction part 1. which visual studio should i use? any express (2012, 2013…) or community...
TRANSCRIPT
![Page 1: C# Introduction Part 1. Which Visual Studio Should I use? Any Express (2012, 2013…) or Community Edition 2013 Any full version](https://reader036.vdocuments.us/reader036/viewer/2022062408/56649f355503460f94c53157/html5/thumbnails/1.jpg)
C# Introduction Part 1
![Page 2: C# Introduction Part 1. Which Visual Studio Should I use? Any Express (2012, 2013…) or Community Edition 2013 Any full version](https://reader036.vdocuments.us/reader036/viewer/2022062408/56649f355503460f94c53157/html5/thumbnails/2.jpg)
Which Visual Studio Should I use?
• Any Express (2012, 2013…) or Community Edition 2013• Any full version
![Page 3: C# Introduction Part 1. Which Visual Studio Should I use? Any Express (2012, 2013…) or Community Edition 2013 Any full version](https://reader036.vdocuments.us/reader036/viewer/2022062408/56649f355503460f94c53157/html5/thumbnails/3.jpg)
.Net framework
• Class Libraries …Console.ReadLine• MSIL• CLR
![Page 4: C# Introduction Part 1. Which Visual Studio Should I use? Any Express (2012, 2013…) or Community Edition 2013 Any full version](https://reader036.vdocuments.us/reader036/viewer/2022062408/56649f355503460f94c53157/html5/thumbnails/4.jpg)
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();
}
}
}
![Page 5: C# Introduction Part 1. Which Visual Studio Should I use? Any Express (2012, 2013…) or Community Edition 2013 Any full version](https://reader036.vdocuments.us/reader036/viewer/2022062408/56649f355503460f94c53157/html5/thumbnails/5.jpg)
IDE, Projects, solutions, debug and release mode, …
C:\Users\<yourname>\Documents\Visual Studio 2013\Projects - default
Highly Recommend
Use C:\Projects\MIS118
.sln (open using Notepad -> it is xml)
Look at using .csproj
![Page 6: C# Introduction Part 1. Which Visual Studio Should I use? Any Express (2012, 2013…) or Community Edition 2013 Any full version](https://reader036.vdocuments.us/reader036/viewer/2022062408/56649f355503460f94c53157/html5/thumbnails/6.jpg)
Debugging, Disable Squigglylines
![Page 7: C# Introduction Part 1. Which Visual Studio Should I use? Any Express (2012, 2013…) or Community Edition 2013 Any full version](https://reader036.vdocuments.us/reader036/viewer/2022062408/56649f355503460f94c53157/html5/thumbnails/7.jpg)
Compiling
code.cpp
Assembly language
Machine language
.exe
C/C++old languages
C#.NET languages
com
pilin
gcode.cs
IntermediateLanguage (MSIL)
+ metadata
Machine language
.exe
C# compiler
JIT compiler
code.vb
VB.NET compiler
CommonLanguageRuntime
(CLR)
![Page 8: C# Introduction Part 1. Which Visual Studio Should I use? Any Express (2012, 2013…) or Community Edition 2013 Any full version](https://reader036.vdocuments.us/reader036/viewer/2022062408/56649f355503460f94c53157/html5/thumbnails/8.jpg)
Command Line compile and execution
• C:\Windows\Microsoft.NET\Framework64\v4.0.30319• csc.exe• csc Program.cs
![Page 9: C# Introduction Part 1. Which Visual Studio Should I use? Any Express (2012, 2013…) or Community Edition 2013 Any full version](https://reader036.vdocuments.us/reader036/viewer/2022062408/56649f355503460f94c53157/html5/thumbnails/9.jpg)
Comments, IntelliSense
// . . .
/* . . . */
![Page 10: C# Introduction Part 1. Which Visual Studio Should I use? Any Express (2012, 2013…) or Community Edition 2013 Any full version](https://reader036.vdocuments.us/reader036/viewer/2022062408/56649f355503460f94c53157/html5/thumbnails/10.jpg)
Use Line numbers (Tools->Options)
![Page 11: C# Introduction Part 1. Which Visual Studio Should I use? Any Express (2012, 2013…) or Community Edition 2013 Any full version](https://reader036.vdocuments.us/reader036/viewer/2022062408/56649f355503460f94c53157/html5/thumbnails/11.jpg)
Data Types, variables
x = 2
y = x + 1;
Console.WriteLine(y)
…
3
Need Variables
![Page 12: C# Introduction Part 1. Which Visual Studio Should I use? Any Express (2012, 2013…) or Community Edition 2013 Any full version](https://reader036.vdocuments.us/reader036/viewer/2022062408/56649f355503460f94c53157/html5/thumbnails/12.jpg)
Data Types, variables (cont)
![Page 13: C# Introduction Part 1. Which Visual Studio Should I use? Any Express (2012, 2013…) or Community Edition 2013 Any full version](https://reader036.vdocuments.us/reader036/viewer/2022062408/56649f355503460f94c53157/html5/thumbnails/13.jpg)
C# Variables Declaration and Naming
![Page 14: C# Introduction Part 1. Which Visual Studio Should I use? Any Express (2012, 2013…) or Community Edition 2013 Any full version](https://reader036.vdocuments.us/reader036/viewer/2022062408/56649f355503460f94c53157/html5/thumbnails/14.jpg)
Primitives (though they are Objects)http://msdn.microsoft.com/en-us/library/ms228360(v=vs.90).aspx
object
String
![Page 15: C# Introduction Part 1. Which Visual Studio Should I use? Any Express (2012, 2013…) or Community Edition 2013 Any full version](https://reader036.vdocuments.us/reader036/viewer/2022062408/56649f355503460f94c53157/html5/thumbnails/15.jpg)
Nullable Type (a bit advance)
![Page 16: C# Introduction Part 1. Which Visual Studio Should I use? Any Express (2012, 2013…) or Community Edition 2013 Any full version](https://reader036.vdocuments.us/reader036/viewer/2022062408/56649f355503460f94c53157/html5/thumbnails/16.jpg)
King System.Object
char
stringint
![Page 17: C# Introduction Part 1. Which Visual Studio Should I use? Any Express (2012, 2013…) or Community Edition 2013 Any full version](https://reader036.vdocuments.us/reader036/viewer/2022062408/56649f355503460f94c53157/html5/thumbnails/17.jpg)
Primitives are Objects
![Page 18: C# Introduction Part 1. Which Visual Studio Should I use? Any Express (2012, 2013…) or Community Edition 2013 Any full version](https://reader036.vdocuments.us/reader036/viewer/2022062408/56649f355503460f94c53157/html5/thumbnails/18.jpg)
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");
}
}
}
![Page 19: C# Introduction Part 1. Which Visual Studio Should I use? Any Express (2012, 2013…) or Community Edition 2013 Any full version](https://reader036.vdocuments.us/reader036/viewer/2022062408/56649f355503460f94c53157/html5/thumbnails/19.jpg)
All are objects!!!
![Page 20: C# Introduction Part 1. Which Visual Studio Should I use? Any Express (2012, 2013…) or Community Edition 2013 Any full version](https://reader036.vdocuments.us/reader036/viewer/2022062408/56649f355503460f94c53157/html5/thumbnails/20.jpg)
small integers (singed and unsinged)
![Page 21: C# Introduction Part 1. Which Visual Studio Should I use? Any Express (2012, 2013…) or Community Edition 2013 Any full version](https://reader036.vdocuments.us/reader036/viewer/2022062408/56649f355503460f94c53157/html5/thumbnails/21.jpg)
big integers (singed and unsinged)
![Page 22: C# Introduction Part 1. Which Visual Studio Should I use? Any Express (2012, 2013…) or Community Edition 2013 Any full version](https://reader036.vdocuments.us/reader036/viewer/2022062408/56649f355503460f94c53157/html5/thumbnails/22.jpg)
float and double, decimal
![Page 23: C# Introduction Part 1. Which Visual Studio Should I use? Any Express (2012, 2013…) or Community Edition 2013 Any full version](https://reader036.vdocuments.us/reader036/viewer/2022062408/56649f355503460f94c53157/html5/thumbnails/23.jpg)
Special Floating numbers
(Division by 0)
![Page 24: C# Introduction Part 1. Which Visual Studio Should I use? Any Express (2012, 2013…) or Community Edition 2013 Any full version](https://reader036.vdocuments.us/reader036/viewer/2022062408/56649f355503460f94c53157/html5/thumbnails/24.jpg)
Doubles vs Decimals
![Page 25: C# Introduction Part 1. Which Visual Studio Should I use? Any Express (2012, 2013…) or Community Edition 2013 Any full version](https://reader036.vdocuments.us/reader036/viewer/2022062408/56649f355503460f94c53157/html5/thumbnails/25.jpg)
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
![Page 26: C# Introduction Part 1. Which Visual Studio Should I use? Any Express (2012, 2013…) or Community Edition 2013 Any full version](https://reader036.vdocuments.us/reader036/viewer/2022062408/56649f355503460f94c53157/html5/thumbnails/26.jpg)
Characters and Strings
![Page 27: C# Introduction Part 1. Which Visual Studio Should I use? Any Express (2012, 2013…) or Community Edition 2013 Any full version](https://reader036.vdocuments.us/reader036/viewer/2022062408/56649f355503460f94c53157/html5/thumbnails/27.jpg)
Strings methods* (again later)
![Page 28: C# Introduction Part 1. Which Visual Studio Should I use? Any Express (2012, 2013…) or Community Edition 2013 Any full version](https://reader036.vdocuments.us/reader036/viewer/2022062408/56649f355503460f94c53157/html5/thumbnails/28.jpg)
Immutable String * (again later)
![Page 29: C# Introduction Part 1. Which Visual Studio Should I use? Any Express (2012, 2013…) or Community Edition 2013 Any full version](https://reader036.vdocuments.us/reader036/viewer/2022062408/56649f355503460f94c53157/html5/thumbnails/29.jpg)
StringBuilder* (again later)
![Page 30: C# Introduction Part 1. Which Visual Studio Should I use? Any Express (2012, 2013…) or Community Edition 2013 Any full version](https://reader036.vdocuments.us/reader036/viewer/2022062408/56649f355503460f94c53157/html5/thumbnails/30.jpg)
Variable Scope *(again later)
MyMethod
![Page 31: C# Introduction Part 1. Which Visual Studio Should I use? Any Express (2012, 2013…) or Community Edition 2013 Any full version](https://reader036.vdocuments.us/reader036/viewer/2022062408/56649f355503460f94c53157/html5/thumbnails/31.jpg)
Type Conversion (cast)
![Page 32: C# Introduction Part 1. Which Visual Studio Should I use? Any Express (2012, 2013…) or Community Edition 2013 Any full version](https://reader036.vdocuments.us/reader036/viewer/2022062408/56649f355503460f94c53157/html5/thumbnails/32.jpg)
Back to our example: using integer data type
int x = 2;
int y = x + 1;
Console.WriteLine(y);
![Page 33: C# Introduction Part 1. Which Visual Studio Should I use? Any Express (2012, 2013…) or Community Edition 2013 Any full version](https://reader036.vdocuments.us/reader036/viewer/2022062408/56649f355503460f94c53157/html5/thumbnails/33.jpg)
Case sensitive language
string myName; myName = "Andrew"; Console.WriteLine(myName);
string myname = "Alice"; Console.WriteLine(myname);
one line
![Page 34: C# Introduction Part 1. Which Visual Studio Should I use? Any Express (2012, 2013…) or Community Edition 2013 Any full version](https://reader036.vdocuments.us/reader036/viewer/2022062408/56649f355503460f94c53157/html5/thumbnails/34.jpg)
Introducing var
• Don’t be afraid
var myName1 = "Bill";
![Page 35: C# Introduction Part 1. Which Visual Studio Should I use? Any Express (2012, 2013…) or Community Edition 2013 Any full version](https://reader036.vdocuments.us/reader036/viewer/2022062408/56649f355503460f94c53157/html5/thumbnails/35.jpg)
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;