C# FOR BEGINNERS

  • Hello Guest! Welcome to ConsoleCrunch, to help support our site check out the premium upgrades HERE! to get exclusive access to our hidden content.
  • Unable to load portions of the website...
    If you use an ad blocker addon, you should disable it because it interferes with several elements of the site and blocks more than just adverts.
  • Read Rules Before Posting Post Virus Scans with every program.

Psycho_Coder

Active Poster
Retired Staff
Active Member
Apr 12, 2014
642
481
133
UK
Just today, I am going to be teaching those noobs some basic c# sharp stuff. Things you will need.:
  • Visual stuido 2010. 2012, 2013
  • a brain


Open a console application in c#
Ok, So let's get started. This si going to nice and short. Let's start off with comments shall we. Comment is the same as in nearly every other programming language. Here is is.

Code:
//Hello world

Knowing that, You are going to need to place this code at the very start because if you don't have this code nothing will run at all. Here is the code.

Code:
using: System;

Now let's move on a class. Now, For me, it is not highly important to have a specific class, as this is not a hight developed tutorial. You can put any.

Code:
class Hello world

Now, because you have got the class there you are now going to want to define it below. You will have to use the "main" function, This is used and tell the computer that you want it to be a program.

Code:
{
static void main(){

}
}

You are now going to want to actually make the program produce the hello world. It should look something like this.

Code:
Console.WriteLine(""Hello world);

Now, let's say you're wanting to exit the program but it does not let you? You would do this.
Code:
Console.WriteLine("Press any key to exit.");
Console.ReadKey();

Let's make sure the windows stays open while we are debug mode.

Code:
//Keep window open in debug mode

Another comment, to show how to run the program

Code:
//Press F5 to run it

Now, This is what the code looks like all together.

Code:
Using system;

class hello world {
static void main() {
console.WriteLine("Hello world");
Console.WriteLine("Press any key to exit");
Console.ReadKey();
//Keep open in debug mode
//Press F5 to run
}
}

You have just created your first program.
 
Also, For those who are using an Windows Form Application Replace
"console.WriteLine" with "MessageBox.Show"
 
General chit-chat
Help Users
  • Chat Bot:
    Benders is our newest member. Welcome!
  • @ ShutTheCrunchUp:
    Damn bro miss the good ol days
    +1
  • Chat Bot:
    QM|T_JinX has joined the room.
  • Chat Bot:
    lordKenny is our newest member. Welcome!
  • Chat Bot:
    yotatouch is our newest member. Welcome!
  • Chat Bot:
    maikito is our newest member. Welcome!
  • Chat Bot:
    maikito is our newest member. Welcome!
  • Chat Bot:
    QM|T_JinX has joined the room.
  • Chat Bot:
    maikito has posted a new reply in the thread "GTA V Semjases 15.3 ModLoader".
  • Chat Bot:
    QM|T_JinX has joined the room.
  • Chat Bot:
    fpcest1 is our newest member. Welcome!
  • Chat Bot:
    BOBO@dics is our newest member. Welcome!
  • Chat Bot:
    QM|T_JinX has joined the room.
  • @ lurch6661:
    lurch 4 life
    +1
  • Chat Bot:
    QM|T_JinX has joined the room.
  • Chat Bot:
    QM|T_JinX has joined the room.
  • Chat Bot:
    rikvipzacom is our newest member. Welcome!
  • Chat Bot:
    QM|T_JinX has joined the room.
  • Chat Bot:
    sschknn is our newest member. Welcome!
  • Chat Bot:
    dragonhelder is our newest member. Welcome!
  • @ xDmTx:
    Holy shit this is still alive?
  • @ xDmTx:
    haven’t been here for years
    +1
  • Chat Bot:
    QM|T_JinX has joined the room.
  • @ QM|T_JinX:
    xDmTx said:
    haven’t been here for years
    well welcome back then
      @ QM|T_JinX: haven’t been here for years well welcome back then