For Beginners @shahedC WakeUpAndCode.com. Introduction > Variables, Operators & Loops > Classes &...
-
Upload
andrea-ball -
Category
Documents
-
view
221 -
download
0
Transcript of For Beginners @shahedC WakeUpAndCode.com. Introduction > Variables, Operators & Loops > Classes &...
![Page 1: For Beginners @shahedC WakeUpAndCode.com. Introduction > Variables, Operators & Loops > Classes & Methods > Files & Exceptions Additional Topics.](https://reader035.fdocuments.net/reader035/viewer/2022062421/56649e175503460f94b036b9/html5/thumbnails/1.jpg)
By Shahed ChowdhuriSr. Technical Evangelist
C# Crash CourseFor Beginners
@shahedC
WakeUpAndCode.com
![Page 2: For Beginners @shahedC WakeUpAndCode.com. Introduction > Variables, Operators & Loops > Classes & Methods > Files & Exceptions Additional Topics.](https://reader035.fdocuments.net/reader035/viewer/2022062421/56649e175503460f94b036b9/html5/thumbnails/2.jpg)
Agenda
Introduction
> Variables, Operators & Loops> Classes & Methods> Files & Exceptions
Additional Topics
![Page 3: For Beginners @shahedC WakeUpAndCode.com. Introduction > Variables, Operators & Loops > Classes & Methods > Files & Exceptions Additional Topics.](https://reader035.fdocuments.net/reader035/viewer/2022062421/56649e175503460f94b036b9/html5/thumbnails/3.jpg)
My BackgroundPeriod Background/Experience
1997 – present
Microsoft web/software development
2011 XNA games on XBLIG for Xbox 360• 2D Math Panic• Angry Zombie Ninja Cats
2012 Tools for XNA developers• XBLIG Sales Data Analyzer (OnekSoftLabs.com)• XNA Basic Starter Kit (CodePlex)
Online: http://facebook.com/OnekSoftGames
![Page 4: For Beginners @shahedC WakeUpAndCode.com. Introduction > Variables, Operators & Loops > Classes & Methods > Files & Exceptions Additional Topics.](https://reader035.fdocuments.net/reader035/viewer/2022062421/56649e175503460f94b036b9/html5/thumbnails/4.jpg)
My Background (continued)Period Background/Experience
2013 • Ninja Cat Runner on Win8, WP8, Web (Construct 2)• Video Q&A with MS Tech Evangelist Frank La Vigne• Founder/Admin of FB groups: Construct2, Xbox One & Unity Indie
Devs• Started Public Speaking in DC area and East Coast
2014 • Public Speaking on Indie Game Development• Joined Microsoft as a Sr. Technical Evangelist• Gallant Glider on Win8, WP8, Web (Construct 2 Universal App)
Video Q&A: http://youtu.be/lRjrQPvVOpo MVA: http://aka.ms/DevGames-Const2
![Page 5: For Beginners @shahedC WakeUpAndCode.com. Introduction > Variables, Operators & Loops > Classes & Methods > Files & Exceptions Additional Topics.](https://reader035.fdocuments.net/reader035/viewer/2022062421/56649e175503460f94b036b9/html5/thumbnails/5.jpg)
Official Xbox Magazine
Source: Official Xbox Magazine, March 2014, Page 65
`
![Page 6: For Beginners @shahedC WakeUpAndCode.com. Introduction > Variables, Operators & Loops > Classes & Methods > Files & Exceptions Additional Topics.](https://reader035.fdocuments.net/reader035/viewer/2022062421/56649e175503460f94b036b9/html5/thumbnails/6.jpg)
Introduction
![Page 7: For Beginners @shahedC WakeUpAndCode.com. Introduction > Variables, Operators & Loops > Classes & Methods > Files & Exceptions Additional Topics.](https://reader035.fdocuments.net/reader035/viewer/2022062421/56649e175503460f94b036b9/html5/thumbnails/7.jpg)
Download & Install Visual Studio
90-day Trial
Express (free)
http://www.visualstudio.com/downloads
![Page 8: For Beginners @shahedC WakeUpAndCode.com. Introduction > Variables, Operators & Loops > Classes & Methods > Files & Exceptions Additional Topics.](https://reader035.fdocuments.net/reader035/viewer/2022062421/56649e175503460f94b036b9/html5/thumbnails/8.jpg)
Visual Studio UI (User Interface)
References
PropertiesPanel
Code Editor
Toolbar
SolutionExplorer
Ouput
Start (Run)
![Page 9: For Beginners @shahedC WakeUpAndCode.com. Introduction > Variables, Operators & Loops > Classes & Methods > Files & Exceptions Additional Topics.](https://reader035.fdocuments.net/reader035/viewer/2022062421/56649e175503460f94b036b9/html5/thumbnails/9.jpg)
Why Learn C#?
Hint: In Visual Studio, click File New Project
![Page 10: For Beginners @shahedC WakeUpAndCode.com. Introduction > Variables, Operators & Loops > Classes & Methods > Files & Exceptions Additional Topics.](https://reader035.fdocuments.net/reader035/viewer/2022062421/56649e175503460f94b036b9/html5/thumbnails/10.jpg)
How Does It Work?
Source: http://www.dotnetspark.com/tutorialpic/clr.png
![Page 11: For Beginners @shahedC WakeUpAndCode.com. Introduction > Variables, Operators & Loops > Classes & Methods > Files & Exceptions Additional Topics.](https://reader035.fdocuments.net/reader035/viewer/2022062421/56649e175503460f94b036b9/html5/thumbnails/11.jpg)
Demo (with debugging/breakpoints)
Hint: Press F9 on any statement to toggle breakpoints
Start/Continue
![Page 12: For Beginners @shahedC WakeUpAndCode.com. Introduction > Variables, Operators & Loops > Classes & Methods > Files & Exceptions Additional Topics.](https://reader035.fdocuments.net/reader035/viewer/2022062421/56649e175503460f94b036b9/html5/thumbnails/12.jpg)
Variables, Operators & Loops
![Page 13: For Beginners @shahedC WakeUpAndCode.com. Introduction > Variables, Operators & Loops > Classes & Methods > Files & Exceptions Additional Topics.](https://reader035.fdocuments.net/reader035/viewer/2022062421/56649e175503460f94b036b9/html5/thumbnails/13.jpg)
C# Language Syntax
Variables
classMethod ( )
Data Types• Integer• String• var?
Assignment
Output
namespace
using statements
// 1-line comment
/* multi-linecomments */
![Page 14: For Beginners @shahedC WakeUpAndCode.com. Introduction > Variables, Operators & Loops > Classes & Methods > Files & Exceptions Additional Topics.](https://reader035.fdocuments.net/reader035/viewer/2022062421/56649e175503460f94b036b9/html5/thumbnails/14.jpg)
Demo (language syntax)
![Page 15: For Beginners @shahedC WakeUpAndCode.com. Introduction > Variables, Operators & Loops > Classes & Methods > Files & Exceptions Additional Topics.](https://reader035.fdocuments.net/reader035/viewer/2022062421/56649e175503460f94b036b9/html5/thumbnails/15.jpg)
Operators (Math, Assignment)Type Operators
Unary Postfix Operators ++ --
Unary Prefix Operators ++ -- + -
Multiplicative Operators * / % (modulus)
Additive Operators + -
Assignment Operators =
Precedence
hig
her
low
er
![Page 16: For Beginners @shahedC WakeUpAndCode.com. Introduction > Variables, Operators & Loops > Classes & Methods > Files & Exceptions Additional Topics.](https://reader035.fdocuments.net/reader035/viewer/2022062421/56649e175503460f94b036b9/html5/thumbnails/16.jpg)
Logical OperatorsType Operators
Equality == !=
Logical AND &
Logical XOR ^
Conditional AND &&
Conditional OR ||
Conditional Ternary Operator ?:
![Page 17: For Beginners @shahedC WakeUpAndCode.com. Introduction > Variables, Operators & Loops > Classes & Methods > Files & Exceptions Additional Topics.](https://reader035.fdocuments.net/reader035/viewer/2022062421/56649e175503460f94b036b9/html5/thumbnails/17.jpg)
Demo (operators)
![Page 18: For Beginners @shahedC WakeUpAndCode.com. Introduction > Variables, Operators & Loops > Classes & Methods > Files & Exceptions Additional Topics.](https://reader035.fdocuments.net/reader035/viewer/2022062421/56649e175503460f94b036b9/html5/thumbnails/18.jpg)
StringsDeclare & Assign
StringBuilder
Special CharactersConcatenateLiteral
string.Format()Char Array
StringFunctions
![Page 19: For Beginners @shahedC WakeUpAndCode.com. Introduction > Variables, Operators & Loops > Classes & Methods > Files & Exceptions Additional Topics.](https://reader035.fdocuments.net/reader035/viewer/2022062421/56649e175503460f94b036b9/html5/thumbnails/19.jpg)
Demo (strings)
![Page 20: For Beginners @shahedC WakeUpAndCode.com. Introduction > Variables, Operators & Loops > Classes & Methods > Files & Exceptions Additional Topics.](https://reader035.fdocuments.net/reader035/viewer/2022062421/56649e175503460f94b036b9/html5/thumbnails/20.jpg)
Loops, etc
for loop
while loop
continue
break
switch-case statements
default break
if/elseblocks
![Page 21: For Beginners @shahedC WakeUpAndCode.com. Introduction > Variables, Operators & Loops > Classes & Methods > Files & Exceptions Additional Topics.](https://reader035.fdocuments.net/reader035/viewer/2022062421/56649e175503460f94b036b9/html5/thumbnails/21.jpg)
Demo (loops, etc)
![Page 22: For Beginners @shahedC WakeUpAndCode.com. Introduction > Variables, Operators & Loops > Classes & Methods > Files & Exceptions Additional Topics.](https://reader035.fdocuments.net/reader035/viewer/2022062421/56649e175503460f94b036b9/html5/thumbnails/22.jpg)
Classes & Methods
![Page 23: For Beginners @shahedC WakeUpAndCode.com. Introduction > Variables, Operators & Loops > Classes & Methods > Files & Exceptions Additional Topics.](https://reader035.fdocuments.net/reader035/viewer/2022062421/56649e175503460f94b036b9/html5/thumbnails/23.jpg)
Creating a New Class
1. Right-click project2. Click Add3. Click Class…
1
23
![Page 24: For Beginners @shahedC WakeUpAndCode.com. Introduction > Variables, Operators & Loops > Classes & Methods > Files & Exceptions Additional Topics.](https://reader035.fdocuments.net/reader035/viewer/2022062421/56649e175503460f94b036b9/html5/thumbnails/24.jpg)
Parts of a Class
constructors
properties
Instancevariable
public method
privatemethods(overloaded)
class declaration
this keyword
![Page 25: For Beginners @shahedC WakeUpAndCode.com. Introduction > Variables, Operators & Loops > Classes & Methods > Files & Exceptions Additional Topics.](https://reader035.fdocuments.net/reader035/viewer/2022062421/56649e175503460f94b036b9/html5/thumbnails/25.jpg)
Inheritance & Complex Objectsparent class
complex object
publicmethod
private variable
![Page 26: For Beginners @shahedC WakeUpAndCode.com. Introduction > Variables, Operators & Loops > Classes & Methods > Files & Exceptions Additional Topics.](https://reader035.fdocuments.net/reader035/viewer/2022062421/56649e175503460f94b036b9/html5/thumbnails/26.jpg)
Demo (classes)
![Page 27: For Beginners @shahedC WakeUpAndCode.com. Introduction > Variables, Operators & Loops > Classes & Methods > Files & Exceptions Additional Topics.](https://reader035.fdocuments.net/reader035/viewer/2022062421/56649e175503460f94b036b9/html5/thumbnails/27.jpg)
Files & Exceptions
![Page 28: For Beginners @shahedC WakeUpAndCode.com. Introduction > Variables, Operators & Loops > Classes & Methods > Files & Exceptions Additional Topics.](https://reader035.fdocuments.net/reader035/viewer/2022062421/56649e175503460f94b036b9/html5/thumbnails/28.jpg)
Add Text File
1. Right-click project2. Click Add3. Click New Item…
1
23
![Page 29: For Beginners @shahedC WakeUpAndCode.com. Introduction > Variables, Operators & Loops > Classes & Methods > Files & Exceptions Additional Topics.](https://reader035.fdocuments.net/reader035/viewer/2022062421/56649e175503460f94b036b9/html5/thumbnails/29.jpg)
Name New Text File
1. Select “General”2. Select “Text File”3. Name it.
1
2
3
![Page 30: For Beginners @shahedC WakeUpAndCode.com. Introduction > Variables, Operators & Loops > Classes & Methods > Files & Exceptions Additional Topics.](https://reader035.fdocuments.net/reader035/viewer/2022062421/56649e175503460f94b036b9/html5/thumbnails/30.jpg)
Update Text File And Properties
Set to “Copy always”enter sample
data
![Page 31: For Beginners @shahedC WakeUpAndCode.com. Introduction > Variables, Operators & Loops > Classes & Methods > Files & Exceptions Additional Topics.](https://reader035.fdocuments.net/reader035/viewer/2022062421/56649e175503460f94b036b9/html5/thumbnails/31.jpg)
Read File, Handle Exceptions
Use System.IO namespace forStreamReader
Handle possibleexceptions withtry-catch block
![Page 32: For Beginners @shahedC WakeUpAndCode.com. Introduction > Variables, Operators & Loops > Classes & Methods > Files & Exceptions Additional Topics.](https://reader035.fdocuments.net/reader035/viewer/2022062421/56649e175503460f94b036b9/html5/thumbnails/32.jpg)
Demo (read text file)
![Page 33: For Beginners @shahedC WakeUpAndCode.com. Introduction > Variables, Operators & Loops > Classes & Methods > Files & Exceptions Additional Topics.](https://reader035.fdocuments.net/reader035/viewer/2022062421/56649e175503460f94b036b9/html5/thumbnails/33.jpg)
Additional Topics
![Page 34: For Beginners @shahedC WakeUpAndCode.com. Introduction > Variables, Operators & Loops > Classes & Methods > Files & Exceptions Additional Topics.](https://reader035.fdocuments.net/reader035/viewer/2022062421/56649e175503460f94b036b9/html5/thumbnails/34.jpg)
• Enumerators, e.g. enum keyword• Extension Methods• Generics• List, e.g. List<int> • Dictionary, e.g. Dictionary<string, string>• Linq
Also Learn…
![Page 35: For Beginners @shahedC WakeUpAndCode.com. Introduction > Variables, Operators & Loops > Classes & Methods > Files & Exceptions Additional Topics.](https://reader035.fdocuments.net/reader035/viewer/2022062421/56649e175503460f94b036b9/html5/thumbnails/35.jpg)
• C# Fundamentals for Absolute Beginners: • http://
www.microsoftvirtualacademy.com/training-courses/c-fundamentals-for-absolute-beginners
• Programming in C# Jump Start:• http://
www.microsoftvirtualacademy.com/training-courses/developer-training-with-programming-in-c
Videos on Microsoft Virtual Academy