I will assume you have already downloaded and installed Visual Studio 2008 or 2010 and got used to the interface already.
C# is an object oriented language. That means everything is an object. Start off by opening Visual Studio (C# of course) and making a new project. Make it a console application and name or Hello World or some shiz.
This should be the code you see:
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
classProgram
{
staticvoid Main(string[] args)
{
}
}
}
Code:
Console.WriteLine("HelloWorld");
It should look like this:
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
classProgram
{
staticvoid Main(string[] args)
{
Console.WriteLine("HelloWorld");
}
}
}
o ahead and run it. It should display "HelloWorld" in Command Prompt.
Now here comes the part that should help you. I will break down the code.
In the coding, there are 3 blocks.
"namespace (Something goes here)" This simply defines a namespace which is a general way to group code.
"class Program" defines an object.
"static void Main(string[]args)" defines a function called Main. It is your starting point for the program.
Classes: Classes are made out of a combination of data and functions. Functions are things that do something to an object.
Placing comments: There are two ways to place comments. Theres could possibly be more by I don't think so.
You can place "//" and type something in after and it won't effect your program. You can also place "/*" at the begginning of a comment and "*/" at the end. I'll show an example in some helloworld code:
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
classProgram
{
staticvoid Main(string[] args)
{
Console.WriteLine("HelloWorld");
//trololol
//noobnoob
/*Hiya you st00pid noob
Go suck a lollipop.*/
}
}
}
Credits:
GalionKnight