Lesson1 - How to make your first c# programe

10/02/2007 13:28 InsaneCoder#1
hi

i have decided to do a toturial every week on step to step guide on using c# to the fullest im aiming to get whoever reads my toturials to stage where he can atleast code his own small project on w/e he wishes but im gana go from the real basics to the expert lvl i hope u guys enjoy it.

today i will be showing you how to make a C# programe very very basic
this will give you a genral idea on some of the stuff on c# this is what you will be needing.

you will need following :-

a computer :P
Windows XP
Visual C # ( i am using 2005 i prefer it but u can choose a updated version
if you choose to)

if you have this YOU ARE READY :D !

lets begin

Step One

open up you Visual c# programe there should be a start page, click on
File and then New Project.. in Name: type Hello World this is our projects name and click on the Windows Application once you have done this sucesfully please click Ok and it will create your form.

Step Two

You will have a Form1 as you can see and right next to it is a tab called
ToolBox. toolbox has all the neceserry buttons, text boxes ect you will be using this in your application in the future and is a big Help.

but for know we will only useing the AB button click and drag this on to your Form1 anywhere is OK just dont place it outside of you form.

you will see know once you let go that a button has been placed you can change the buttons name buttons name and properties but for now i wont tell that maybe in future totrials.

Step Three

go ahead and double click the Button automatically you will see a code interface pops up this is where you will be spending most your time when u code your own software or programs you can switch between the Disgin view and Form1.cs * view on the tabs above i presume they will not be hard to find :P.

Step Four

know for the fun bit when you click on your button a code interface appears you will se somthing like this :-

namespace HelloWorld
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
THIS IS WHERE YOU WILL RIGHT YOUR CODE
}
}
}


looks complicating? dont worry later on will get much easier we will be righting 1 code line in between the curley braces where i have high lighted
what are the curley braces you might ask? {} <<-- they are just to make life easier in between is where you right ur code this is called a code block i would like you to use that termnolgy atm beocoues it will be used in future purposes i dont want you to get confused if you dont right in between them curley braces your code will be invalid and you program wont work

you might ask

private void button1_Click(object sender, EventArgs e)

why dosnt this code be in between the curley braces this is a event handler when you double clicked the button c# IDE - intractive develpmont enviroment automatically added a event ill explain in later toturials what a IDE is so dont worry about it.

to get back on to the point a event handler never bees in between your code line.

Step Five

right know to right the code, where i stated i want you to write the following i would prefrer you dont copy and past coz wont be practical and this will stik in your memory better :D

MessageBox.Show("HelloWorld");

Please follow my toturial and do this....

i will know explain in detail what this code means for the people who dont realy understand...

Messagebox.Show - what this does is once you click your button it will make another little screen that will have your message in it.

(" ") - this brackets are to break your code up and the " " are very imprtant this will be used in the future what they do is tell c# a message is gana be written. if u are gaan write a message it must always start and end with a semi colon "".

; - lastly this is a very imortant code all your codes WILL END WITH THIS; if not you programme will never run it just breaks up a 1 code line to another one. and is very imortant.

Step Six

right so know our code is written go back to your design view, we will test our programme know in debugg view please press F5 on your keyboard and c# will start processing what you write once your the programme appears click your Button1 and a Hello World message will appear :)



Congraulation you have made your first c# programme

this toutrial was amied for NEWLY bigginers in c# Hope you Enjoyed it Please check regulary i will be making a 2nd toturial on Lesson 2 i will be explanning about IDE and how to change properties of your form buttons and start introducing new toolbars and start getting you more familier in the controls.



if you want to ask questions i am willing to answer them :) so dont hasitate
Thx for reading.

InsaneCoder
10/02/2007 20:17 shadycharacter#2
where do you get visual c#?
10/02/2007 21:18 InsaneCoder#3
you can search it in google visual c# download and there loads of places u can download it
10/07/2007 21:22 darkirax#4
thanks for tutorial i'm waiting second part :)
10/07/2007 23:40 bawynne90#5
cool now can you make a tut for checkboxes and other examples
make a autoclicker example
checkbox example
and etc.
good tut keep making em:D
10/08/2007 10:43 InsaneCoder#6
sure i could do that but first we must learn variables, expersions and statments next lesson will be more about IDE and getting to know the enviroment u will be using to code in. im doing this because later as we progress through the totrials some people might know understand a certin aspect of the program i am talking about if i explain it ealier they can refrence to it will make eveyones life much easier.

and to answer shadycharcter here is the link for 2005 c# programme there is a new updated version c# 2007 but i dont reccomend u use it since its still in beta links below enjoy

[Only registered and activated users can see links. Click Here To Register...]

insaneCoder
10/09/2007 01:18 bawynne90#7
if you dont mind can you explain variables, expersions and statments
and how to use them plz?:D
10/10/2007 17:16 InsaneCoder#8
yes i will be the new tut is comming up soon im just finishing it off on IDE i need exlain this first about lesson 3 - 4 will be about variables expressions , and statments
10/10/2007 17:59 Assass1n#9
An alle, die ernsthaft C# lernen wollen: Kauft euch ein Buch oder lest die Hilfe im MSDN durch - dieses Tutorial ist nicht unbedingt der Hammer und ich meine sogar, es schonmal gesehen zu haben - nur mit weniger Rechtschreibfehlern.
10/12/2007 06:47 GohanWarrior#10
is there any way i can open an exe/program that has been made by this i have a program made by this but cant open it as its an exe :S (sorry if thats a newb question but i aint got a clue lol)
10/17/2007 16:12 InsaneCoder#11
serach this in help on c# it tells u how to compile all the files so
it`s a exe. :)