\"Writing.Com
*Magnify*
SPONSORED LINKS
Printed from https://shop.writing.com/main/view_item/item_id/998501-C-A-bored-Programmers-Exploration
Item Icon
\"Reading Printer Friendly Page Tell A Friend
No ratings.
by Shades Author IconMail Icon
Rated: E · Other · Educational · #998501
This will double as a tutorial as well as a journal.
The not quite unchanging Static Piece by Shades.
A guide to C# programming, as well as my own expieriances with the language.
Note:This will be a growing piece, as there is no other way to give a true view of something as complex as programming without revision, and a large bit of length.

Tools:Visual C# 2005 Express Edition Beta 2 Available for free from:http://lab.msdn.microsoft.com/vs2005/

Introduction:This time while learning a new programming language, I decided to try my best to provide a functional tutorial. As such I will update it as I find better practice, and learn new things. I will also be using a large number of links to screen shots due to the visual element of Microsoft's C#.

Part I:The Basics of Setting up a project.
Okay. If you have programmed before you are probably familiar with projects, and their general creation. However, for the new people, and possibly those of you who are new to Microsoft's .NET framework, I will cover basic creation.
On the main screen of the VC#EE 2005 IDE (Integrated Development Enviornment) you will see your basic menu bars, with file, edit, and so on. You will also see a space with recent projects (blank the first time) with open, and create commands. The easiest way to make a new project is to click either the create button under the recent projects, or, File->New project.
From here ,you can select a Windows application, and modify it's name to suit your purposes. For tutorial purposes, let's call it HelloWorld. Sound familiar to some of you? Odds are, if you followed a book, tutorial, or took a class, your first program printed "Hello World!" on the screen.

After a few moments, a blank form will appear. To the right you see the solution view which contains your project, and the properties window. On your left, you should see a tab that says Toolbox. Hover your mouse over this, and at the top right, click the button that looks like a push pin. This will make deisigning your form much easier. Now let's make our first program.
(If any tool bar or box is missing, click view, and select it from there to bring it back)

Click the "button" control in the tool box, and drag it at about the center of your form. A button will be drawn. Now make sure it is selected (click it if it isn't. If you double-click on accident, look at the tabs near the top of the screen, below the toolbars, and click the tab with [design] after the name), and look at the properties dialog.

Scroll down if you have to and find the Text property. Change this to say "Hello". You will notice the text on the button changes. Now find the "(name)" property and name this something like btHello or hellButton. This practice comes in handy in large programs that involve large amounts of code. Now double-click your button.

A new window opens. This is your code view.
You should see something similar to this:
namespace HelloWorld
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show("Hello World");
}
}
}
You will notice I added a MessageBox.Show line. Add this to your program to create a standard message box that displays a string of characters.You can change it to say anything, but for this lesson, use Hello World. When you are finished, press F5. Now click the button and behold. You have just finished your first C# program. You can now go to file->Save all to save your work.

That is the end of this lesson. Before the next lesson, I recommend you play around with your design view. Look at the controls. You don't have to add code to everything you put on the form so you can press F5 and see how it looks,and how you interact with differant tools. You can also resize the form the same way you would a window.


(Want to request a tutorial on a language? Maybe console applications in C#? C or C++?Visual Basic, Perl, or Java? Feel free to send an E-mail and I will post one if and as soon as I can.)
© Copyright 2005 Shades (redhappymask at Writing.Com). All rights reserved.
Writing.Com, its affiliates and syndicates have been granted non-exclusive rights to display this work.
Printed from https://shop.writing.com/main/view_item/item_id/998501-C-A-bored-Programmers-Exploration