[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
BeginnersGuideToCSharp
See the Programmers Heaven C# School for a complete C# tutorial.
This beginner's guide is general, and it should only set the basics in the understanding of C#.
Chapter 1: Introduction to programming in C#
Feel free to add your own questions for others to answer, as long as the scope remains general. And, of course, answer questions if you know the answer.
We will now explain each section of the program.
This lets you use the classes in the namespace System.
The namespace for your Hello World program. This is similar to a package in Java. Namespaces are useful for organizing classes.
This is the main class of you application. All methods, fields, and properties must be contained in a class.
This is the entry point of the application. In a program written in C#, the application always start executing a a public static methed named Main. Main must be capitalized. It can return int or void. I can either have no parameters or have string[] args as its parameters.
This does the job of actually writing "Hello, World!" (without the quotation marks) on the console window. Console is a class in the System namespace. WriteLine is a method in the Console class.
If we had not put the line using System; at the beginning of the program, we would have had the specify the namespace of Console when we called it. This line would then look like this: System.Console.WriteLine("Hello, World!");.
Someone please continue this Beginner's Guide.
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
BeginnersGuideToCSharp
Welcome to the Beginner's Guide to C#
"Hello World!" and welcome to the wonderful C# zone...See the Programmers Heaven C# School for a complete C# tutorial.
This beginner's guide is general, and it should only set the basics in the understanding of C#.
Table of Contents
IntroductionChapter 1: Introduction to programming in C#
Introduction
Some Basic Questions about C#
What is C#?
C# (pronounced "C Sharp") is a new programming language designed from the ground up for the .NET managed runtime environment.What does it do best?
Not answered yet.How is it similar to other programming languages?
It is completely object oriented like Java. It contains operator overloading, preprocessor directives, and function pointers (in the form of delegates) like C++.Why should I use it, rather than other similar compilers?
Not answered yet.Feel free to add your own questions for others to answer, as long as the scope remains general. And, of course, answer questions if you know the answer.
Chapter 1: Introduction to programming in C#
Hello, World!
As always, we will start with teaching you the Hello World program. This program simply prints "Hello, World!" on the console window.
using System;
namespace MyProgram
{
class HelloWorldProgram
{
public static void Main()
{
Console.WriteLine("Hello, World!");
}
}
}
We will now explain each section of the program.
using System;
This lets you use the classes in the namespace System.
namespace MyProgram
The namespace for your Hello World program. This is similar to a package in Java. Namespaces are useful for organizing classes.
class HelloWorldProgram
This is the main class of you application. All methods, fields, and properties must be contained in a class.
public static void Main()
This is the entry point of the application. In a program written in C#, the application always start executing a a public static methed named Main. Main must be capitalized. It can return int or void. I can either have no parameters or have string[] args as its parameters.
Console.WriteLine("Hello, World!");This does the job of actually writing "Hello, World!" (without the quotation marks) on the console window. Console is a class in the System namespace. WriteLine is a method in the Console class.
If we had not put the line using System; at the beginning of the program, we would have had the specify the namespace of Console when we called it. This line would then look like this: System.Console.WriteLine("Hello, World!");.
Someone please continue this Beginner's Guide.
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
