Visual C# tutorial : Create a simple console program / PDF


Visual C# tutorial : Create a simple console program  / PDF



Visual C# tutorial : Create a simple console program  / PDF











For most of the exercises (and homework projects) that you work with in this class, you will normally be given a 'starter project', that contains everything you need to get you started on the exercise/homework assignment.  However, it's good for you to know how to create a new project from scratch.  Go through this exercise, in order to make sure that you're comfortable with creating, compiling, and running (executing) a C# program that you've created yourself.

It is possible to quickly and easily create several different types of applications using visual C#.  We will start by creating what is called a console application -- the steps specified here are largely adapted from those found in your textbook in Chapter 2 – the major difference is that your textbook doesn't use the Visual Studio.Net development environment, but instead uses the .Net SDK & the command line.  While you're welcome to try out how the book does things, I'd strongly recommend that you familiarize yourself with VS.Net, instead.

Step 1:  
Start Microsoft Visual Studio.Net.  It is located in the Start menu atWe’ll be using Microsoft's Visual C# compiler that this quarter.  It is an integrated environment that allows you to edit, build and run C# programs.  You’ll learn more about it as the quarter progresses.

Step 2:  
Create a new project.  Select File>New>Project  from the VS.Net menu bar.  This brings up the New Project window that allows you to select from various items to create, which should look like the one pictured below.  In the Project Types window  (left-hand pane), you want to pick Visual C# Projects. 
            Once you've done that, you want to select from the Templates window the Console Application (note that you'll have to scroll down to find it). You also must type in a project name (such as "Lecture1_Exercise2") and select the directory location where you want the project to be stored.  If you're working at school, you'll wants to store the project in your student folder (H:\, if available) or on your own removable media.  Click Ok and you'll go to the next step.

Step 3:  
You just created C# project, and a C# files containing a nearly-blank program.  Projects store information about all of the files and options that are used to create a C# program.  Files are typically C# source files that have a .cs extension and contain executable C# statements, although there are other file types.
If you examine the code (most of which is explained well by the Deitel book), you'll find a line that reads:
// TODO: Add code to start application here

You want to replace that, with the following boldfaced code, so that the entire file looks exactly like the following:.......







Download Visual C# tutorial : Create a simple console program  / PDF


















Visual C# tutorial : Create a simple console program  / PDF




0 commentaires: