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
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
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
Thx for reading.
InsaneCoder







