Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[C#] Beginner Lessons

Legendary Battlemage
Loyal Member
Joined
Apr 7, 2009
Messages
647
Reaction score
25
UPDATED!
--------------
Prerequisites:
A C# IDE (Visual Studio, SharpDevelop, etc)
Basic knowledge in computer programming

Lesson I: Understanding the Basics
Before you learn to code, you must understand why and how C# was created.

C# is a "son" of C++. C# was created to simplify C++, to compromise between power and easiness.

C
|
C++
/*****\
Java**C#

As you can see, Java is also a "son" of C++. However, Java cannot really be called as C#'s brother, but more like a cousin.

Where can C# be used?
It all depends on the framework you use.
The .NET framework, by Microsoft, is the most commonly used framework. the .NET framework operates ONLY on Windows operating systems.
Another common framework is the open-source Mono framework ( )
The Mono framework supports Linux, Mac OS X, and Windows.

Now, you might be asking, if Mono supports all those OSs, why even use the .NET framework?

The answer is simple.
Updates.

The Mono project will always be behind the .NET framework.
As of now, the Mono project is still behind by a bit.

But otherwise, if you're ok with that, then by all means, go get Mono.

Now, let's get started!

Lesson II: Learning C#'s In/Out System

Vocab to know:
Code block: A segment of code
namespace: a project name
class: a group of like functions and variables
library: a compiled file with functions

C# has a very easy to use I/O system.
To show you this, let's go ahead and make a program.

Create a new console project.
In VS, that would be File > New Project > C# > Console Application. (Other IDEs might have about the same stuff)

Open up the file with the Main() function.

If you don't have a file, or you just have an empty file, your IDE sucks cr...Just kidding.

Make a new file, by right-clicking on the project in the project explorer, and click 'new file'.

If asked what type, choose "Class"

If your file is empty, type this in.

Code:
using System;

namespace MyFirstCSharpApp
{
class Program
{
public static void Main()
{
}
}
}

The "using" block states which libraries to import. In this case, we're importing the System library.

namespace MyFirstCSharpApp
{
}

means that the code inside resides within the MyFirstCSharpApp, well, namespace. :p

Now, the
class Program
{
}
means that we're organizing a bunch of variables and functions into a category of "Program".

and finally,

public static void Main()
{
}

is a function. Main() is the first function called.
We'll talk a bit more about the public, static, and void keywords.
For now, let's just start writing our app.

Inside
public static void Main()
{
and
}
put
Console.WriteLine("My first ever application in C#!");

Now, debug.
Congratz!
You might notice that the console window immediately closes.
to fix that, add Console.ReadLine() under the WriteLine().

Now, let's take a look at the functions we added.
Let's look at the Console.WriteLine() function.

Console, is a class, just like the one you programmed in.
The "." operator opens up all the available functions and variables for use in the class. WriteLine() is a function in the Console. class.
The ("My first ever application in C#)! is what we call a parameter.
It's like a variable that we pass on to the function for use.

I'll write some more when i've got more time.
 
Last edited by a moderator:
Custom Title Activated
Loyal Member
Joined
May 28, 2007
Messages
1,023
Reaction score
164
Re: C# Lessons

Not much of a lesson.
 
Skilled Illusionist
Joined
Apr 22, 2009
Messages
301
Reaction score
19
Re: C# Lessons

It has not much of a tutorial, bad typo, lack the use of
Code:
, and lack of indentation, and you basically don't expolain nothing but how to write 'things' in a fixed order, the goal of a tutorial is actually defining these 'things'.
 
offonline
Loyal Member
Joined
Aug 5, 2009
Messages
1,403
Reaction score
164
Re: C# Lessons

...Orginze it to make it easier to read.:mellow:
 
Junior Spellweaver
Joined
Jul 12, 2008
Messages
130
Reaction score
6
Re: C# Lessons

If you want to add this, it may help a little with your tutorial :D

WriteLine is not part of the C# Language, it is a .Net Method. WriteLine method is a member of the Console class in the System namespace. Furthermore, when using methods like WriteLine, you must use the full name, including the namespace and class name:
System.Console.Write();

The only exception to this, is through using directives, such as the System directive. It saves time when coding. To use this directive correctly you would add this:
using System;

This way instead of typing:
System.Console.WriteLine();

You would type:
Console.WriteLine();
 
Last edited:
Newbie Spellweaver
Joined
Nov 24, 2008
Messages
53
Reaction score
1
Re: C# Lessons

C# is a "son" of C++. C# was created to simplify C++

No thats not true...
Other than that ok tut I guess.
 
Ginger by design.
Loyal Member
Joined
Feb 15, 2007
Messages
2,340
Reaction score
653
Re: C# Lessons

Actuallly, it is true.

C# was created to compete with Java. There's a lot of hints about this in MS documentation, talks, and blogs, lots of hints like how C# is succeeding and pushing Java down a bit and becoming more and more popular etc.

Java was created to be a platform-independent high level language that is similar to C++ so it's not viewed as a new alien language.

C# and C++ don't have a lot in common except the common procedural and object-oriented programming syntax/semantics. A lot of modern languages took the common notations that existed in C and used them because they're concise and make sense. We don't compare PHP to C++ but honestly they are about as comparable as C# is to C++.

The creator of C# even says that the only reason it's called C# is because it borrows on the object-oriented syntax of C++, not that it's in any way made to operate in a similar manner.
 
Last edited:
Legendary Battlemage
Loyal Member
Joined
Apr 7, 2009
Messages
647
Reaction score
25
Re: C# Lessons

C# was also named C# because they hid 4 '+'s in the #.
I read that somewhere lol.
 
Joined
Jun 8, 2007
Messages
1,985
Reaction score
490
Re: C# Lessons

C# was also named C# because they hid 4 '+'s in the #.
I read that somewhere lol.
:blink: Just because you read that somewhere doesn't make it "The reason they named it C#".....

You need to do more cross-referencing and check your sources, sir.

Edit:
Like this one, . Read That.
 
Last edited:
Extreme Coder - Delphi
Loyal Member
Joined
Sep 8, 2007
Messages
1,381
Reaction score
39
Really pointless, most coders can self teach themselves this basic knowledge.
 
Back
Top