Jump to content

  • Log In with Google      Sign In   
  • Create Account


- - - - -

C# Workshop - Prerequisites

  • You cannot reply to this topic
No replies to this topic

#1 JWalsh   Moderators   -  Reputation: 462

Like
0Likes
Like

Posted 20 June 2007 - 06:35 PM

Welcome to the GDNet C# Workshop Prerequisites Thread

For a complete introduction to this workshop, please look here. Workshop Overview This workshop is designed to aid people in their journey to learn beginning C# (C-Sharp). This workshop is targeted at highly motivated individuals who are interested in learning C# or who have attempted to learn C# in the past, but found that without sufficient support and mentoring they were unable to connect all the pieces of this highly complex but powerful programming language. This is a 'guided' self-teaching C# workshop. Each student is responsible for taking the time to read the material and learn the information. Additionally, this workshop does not attempt to defend C# as a language, nor does it attempt to demonstrate that C# is either more or less useful then other programming languages for any particular purpose. People who intend to start a discussion about the differences between C# and ANY other languages (except as are relevant to a particular discussion), are encouraged to do so elsewhere. This workshop is for educational, not philosophical discussions. Finally, the community and tutors that arise out of this workshop are here for making the learning process run more smoothly, but are not obligated to baby-sit a person's progress. Because everyone will be working from the same references (.NET Book Zero and optionally the C# Language Specification 1.2 & 2.0), students may find it easier to get answers to the specific questions they might have. There is no minimum age requirement, and there is no previous programming experience required. However, we will be moving quickly so it's essential that students stay on task and dont fall behind. Visual C# 2005 Express Edition Prerequisites Greetings all! To prepare for the start of the C# Workshop in a week or so, I wanted to take a few moments and demonstrate to everyone how to create a C# Console project and solution in our primary tool - Visual C# 2005 Express Edition. Before I do, however, let me take a brief moment to describe some of the basics. First, when dealing with VC# 2005 EE during the course of this workshop you will be exposed to 3 primary types of files. First, and most important, are *.cs files. These "C-Sharp" files are where our code goes. They are analogous to the .cpp files in C++, and the .c files in C. and the .java files in...wait for it...Java. Each .cs file is a single compilable unit which, when compiled, is converted into a binary stream of data, which, when combined with other binary streams form a .NET assembly. An assembly usually has the extension .exe or .dll, depending on whether the assembly is an application or a library. Which of these the assembly is, is determined in part by whether or not an entry point is defined (static void main), but also in part by the project settings. This brings us to our second type of file, the .csproj file. Every executable or library you create will have an associated project file is an XML based document detailing everything the Microsoft .NET compiler needs to know to build your assembly. Typical information stored in a .csproj file are the build configurations (ie. debug, release, Windows, XBox360, etc..), the ProjectGUID, the name of assembly to create, as well as a listing of all the .cs files which will be compiled into the assembly. Some applications are more complicated, and require a division of content between more than one assembly. Among the many reasons this may happen is if there are reusable custom controls that may be compiled into a Control Library, or if a developer is using Test Driven Design and has a test framework. But regardless of the reason, when more than one assembly (and thus C# project) is involved, it's common to include them within the same solution. This brings us to our third file type, the *.sln. Those that have worked with Visual Studio before will already be familiar with these types. The solution file is just another XML file, similar to the .csproj file, which contains information about where to find the .csproj files for this solution on disk, etc...During the course of this workshop, we will likely only ever be working with a single C# project at a time, and thus, will have little need to mess with the solution. Later workshops will likely break code up into libraries and applications, which WILL result in having multiple projects within a solution. In the mean time, we'll work with what we need. During the course of this workshop we will be almost entirely interested in Console applications. This gives us the ability to see our code executed and the output displayed on the screen, without the overhead of having to deal with a windows framework (regardless of how power WinForms or WPF may happen to be). When you first open Visual C# 2005 EE you'll see a screen similar to this. Note that in the above screen the list of recent projects shows up in the top left. Also, although I've made the screen relatively small to fit here in the forums easily, the Start Page for C# 2005 EE often has links to interesting articles and resources, especially if you've got the XNA Game Studio installed over top of C# 2005 EE. In order to get started, you'll open up the file menu and either click open, or new. Since we're assuming we've never created a project or solution before, we'll click new. After doing so you'll get a screen similar to the following. Although the list of available project types may be different, you're guaranteed to have the one we're most interested in. Console Application. Just click on it, give your project a name (generally the name of the .exe you want), and then click OK. Once you've done all of the above you'll see the default, starting console code and Solution. Notice in the Source Code view there's a default namespace, a default class, and the entry point for all C# Console Applications - static void Main. You'll also notice in the image below that it created a default solution and project, named the same. This is fine, and as mentioned above, for the purpose of this Workshop, it's unlikely you'll need to create additional projects within the solution, except perhaps for the final project. Once you've gotten this far, simply hit F6 on your keyboard to build the application, or hit CTRL+F5 to build and launch the application. This will display the output of the executable in a console window. Make note, this is not a "Debug" mode. To launch the application in Debug mode hit F5 by itself (no CTRL). Be aware, however, that when you launch a console application in Debug mode, without a prompt for user interaction, it will close immediately after opening. Well, this wraps up the prerequisites. From here, you should be able to implement the "Hello, World" program demonstrated in Chapter 1 of the Specification. And you should be able to complete the first Exercise in the Chapter 1 & 2 Review Quiz. Summary Step 1: File->New Step 2: Click Console Application Step 3: Give the application a name and press OK Test: Step 4: Hit F6 to build, or CTRL+F5 To Build and Launch Step 5: Make changes to the code-base goto Test; Cheers! [Edited by - JWalsh on July 21, 2007 10:29:06 PM]
Jeromy Walsh
Sr. Tools & Engine Programmer | Software Engineer
Microsoft Windows Phone Team
GameDevelopedia.com - Blog & Tutorials
GDNet Mentoring: XNA Workshop | C# Workshop | C++ Workshop
"The question is not how far, the question is do you possess the constitution, the depth of faith, to go as far as is needed?" - Il Duche, Boondock Saints

Sponsor:




PARTNERS