Introduction to Programming with C#

Reviews
Shared by: IBDa Joker
Stats
views:
160
rating:
not rated
reviews:
0
posted:
1/23/2009
language:
English
pages:
0
Introduction to Programming with C# Curtis Bennett xnagamemaking.com Objectives Learn the basic concepts of programming  Set up Visual C# Express and XNA  Create a simple C# program  What is Programming? Tell the computer what to do.  Give instructions and manage data.  Write code – series of instructions.  Computer Languages Computers only understand binary (zeroes and ones) but we write in higher level languages that are translated into binary (eventually).  Syntax – specific way to write in a language  C, C++, Java, Visual Basic, C#  Compiler Translates code into a program.  Takes computer code in a language (C#) and changes it into code closer to what the machine can understand (byte code).  to build or compile a program – change computer code to byte code.  Visual C# is our compiler  Types of Languages Structured – Procedural  Object-Oriented (OO)  List based, relational. (Much rarer than Structured and OO)  Structured – Procedural All computer code runs in a very linear fashion.  Programs run just first statement after the other.  C, Basic  Object-Oriented Arranges programs in a different way.  Much closer to real life.  We cover what objects are later.  C++, Smalltalk, Java, C#  C# Procedural Object-Oriented C# is our language.  C# is OO but inside Objects code is put in little procedural sections (blocks).  At first we won’t worry about Objects.  What is XNA? XNA is some additional libraries Microsoft made for developing games.  Not part of C#, but an addition.  Won’t cover it until Part II.  Getting Visual C# and XNA  Goto: http://creators.xna.com/Education/newtoxna.a spx Download and install Visual C#  Download and install XNA  First C# Program Will print out “Hello World!” on the screen.  Console Program – just text.  First C# Program Start XNA Game Studio Express  File->New Project  Select “Console Application” icon.  In name type “HelloWorld” and click OK.  File->Save All – Can choose a place to put it.  First C# Program  Add the following highlighted text into the program: using System; using System.Collections.Generic; using System.Text; namespace HelloWorld { class Program { static void Main(string[] args) { Console.WriteLine("Hello World!"); } } } First C# Program – Running After the change to the program, goto Debug->Start Debugging or hit F5.  Displayed is a console. Press any key for the program to exit.  If it didn’t run correctly make sure the changes in the previous slide were typed in exactly as shown.  First C# Program – Line by Line    C# gives a lot of different instructions we can use, but we want to tell C# which of the instructions we'll be using. We don't want C# to give us every available instruction, since we won't use most of them and it adds overhead to the program to say we'll use more instructions then we need. The first part of the program tells C# what instructions we'll use: using System; using System.Collections.Generic; using System.Text; First C# Program – Line by Line Note that each of the commands ends with a semicolon.  The semicolon is a way of telling C# that an instruction is complete.  The amount of whitespace (spaces, tabs, returns) after an instruction doesn't matter, that the semicolon is there is all that counts.  First C# Program – Line by Line      C# defines blocks of code by brackets {}. The previous code put everything into three blocks. First block defines a namespace block, second block class Program defines an object. The final block static void Main(string[] args) defines a function (or method), a group of statements that together form a common task. Main is the entry point for the program. When we start the program it starts running instructions from Main. First C# Program – Line by Line  These two lines do the work: Console.WriteLine("Hello World!"); Console.ReadKey();   They each tell the console something to do (print and pause until a key is pressed). The “Hello World!” Is in quotations because it is some string – written text that’s not computer code. Comments Statements that are ignored by the compiler.  Single line comment //  // Print out Hello World! Console.WriteLine("Hello World!");  Multiline comment /* … */ /* Print out Hello World! */ Console.WriteLine("Hello World!");  Documentation comment /// Next Time Look at storing and changing data.  More complex C# program. 

Related docs
C Programming
Views: 691  |  Downloads: 107
Introduction to C programming
Views: 87  |  Downloads: 16
Introduction to C Programming
Views: 80  |  Downloads: 22
Introduction to Programming in C
Views: 81  |  Downloads: 7
Introduction to Programming
Views: 57  |  Downloads: 9
Essential C Programming
Views: 143  |  Downloads: 28
Introduction To Programming
Views: 79  |  Downloads: 5
C programming
Views: 120  |  Downloads: 27
Introduction to C# Programming with Microsoft
Views: 70  |  Downloads: 9
Introduction to C Programming
Views: 3  |  Downloads: 0
C Programming Language
Views: 747  |  Downloads: 98
Introduction-to-Programming
Views: 0  |  Downloads: 0
premium docs
Other docs by IBDa Joker
Sample emergency procedures
Views: 352  |  Downloads: 9
Board Resolution Authorizing Litigation
Views: 153  |  Downloads: 3
Applicant work history forms
Views: 457  |  Downloads: 5
Agreement Regarding Relationship with Co-Worker
Views: 760  |  Downloads: 16
LAST WILL AND TESTAMENT FORM
Views: 1087  |  Downloads: 68
INDEMNITY AGREEMENT
Views: 305  |  Downloads: 7
Stock Subscription Package
Views: 399  |  Downloads: 30
Gotocom Inc Ammendments and Bylaws
Views: 266  |  Downloads: 0
Job Performance Feedback Form
Views: 1431  |  Downloads: 51
Absence policies
Views: 430  |  Downloads: 21
Employee Exit Interview
Views: 298  |  Downloads: 12
Hypnosis Studies on weight loss
Views: 845  |  Downloads: 9