• 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
  • No one is chatting at the moment.
  • Chat Bot:
    cPwqA is our newest member. Welcome!
  • Chat Bot:
    keonhacaifootball is our newest member. Welcome!
  • Chat Bot:
    QM|T_JinX has joined the room.
  • Chat Bot:
    Keonhacai5vip11 is our newest member. Welcome!
  • Chat Bot:
    smoore99 is our newest member. Welcome!
  • Chat Bot:
    Pagliosa is our newest member. Welcome!
  • Chat Bot:
    QM|T_JinX has joined the room.
  • Chat Bot:
    prototypefox is our newest member. Welcome!
  • Chat Bot:
    maogege is our newest member. Welcome!
  • Chat Bot:
    ShadowPsy974 is our newest member. Welcome!
  • Chat Bot:
    Ghost8099 is our newest member. Welcome!
  • @ Ghost8099:
    Yurrrrrr
  • @ Ghost8099:
    Can we get a new link here brotha
  • Chat Bot:
    Mason Fo has left the room.
  • Chat Bot:
    QM|T_JinX has joined the room.
  • Chat Bot:
    wzxcvcv is our newest member. Welcome!
  • Chat Bot:
    cnood is our newest member. Welcome!
  • Chat Bot:
    zoumar is our newest member. Welcome!
  • Chat Bot:
    bestsmmlike is our newest member. Welcome!
  • Chat Bot:
    josuelton silva is our newest member. Welcome!
  • Chat Bot:
    josuelton silva has posted a new reply in the thread "Console ID #8671".
  • Chat Bot:
    ideasforlifetv is our newest member. Welcome!
  • Chat Bot:
    QM|T_JinX has joined the room.
  • Chat Bot:
    Christo has joined the room.
      Chat Bot: Christo has joined the room.
      Back
      Top