• 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.

C# FOR BEGINNERS

Psycho_Coder

Active Poster
Retired Staff
Active Member
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
  • @ God:
    It’s going good. So we will see what happens and if the site can come back like it was or better
  • @ QM|T_JinX:
    nice yea lets hope
  • @ QM|T_JinX:
    im going to play some red dead it was great to have spoken to you bro nice to see you back on here
  • @ QM|T_JinX:
    hope you have a great night bro
  • @ God:
    It was good talking with you as well, you have a great night! We will talk later bro
    +1
  • Chat Bot:
    QM|T_JinX has joined the room.
  • @ QM|T_JinX:
    have a great weekend everybody ill be back after the weekend
  • Chat Bot:
    OkBrruh is our newest member. Welcome!
  • Chat Bot:
    uncrtin is our newest member. Welcome!
  • Chat Bot:
    BigTechModz is our newest member. Welcome!
  • @ BigTechModz:
    Hey this is RexMods I don’t remember the login to my old account so I made a new one I am now known as BigTechModz
  • Chat Bot:
    QM|T_JinX has joined the room.
  • Chat Bot:
    QM|T_JinX has joined the room.
  • Chat Bot:
    iDior2K is our newest member. Welcome!
  • Chat Bot:
    QM|T_JinX has joined the room.
  • Chat Bot:
    KillerDino49 is our newest member. Welcome!
  • Chat Bot:
    Xiomber is our newest member. Welcome!
  • Chat Bot:
    QM|T_JinX has joined the room.
  • Chat Bot:
    QM|T_JinX has joined the room.
  • Chat Bot:
    QM|T_JinX has joined the room.
  • Chat Bot:
    051magalhães is our newest member. Welcome!
  • Chat Bot:
    wheelcore is our newest member. Welcome!
  • Chat Bot:
    QM|T_JinX has joined the room.
  • Chat Bot:
    zeppiemods66 is our newest member. Welcome!
  • Chat Bot:
    Scrapper is our newest member. Welcome!
      Chat Bot: Scrapper is our newest member. Welcome!
      Back
      Top