[Home]  [Edit this page]  [Recent Changes]  [Special Pages]  [Help
WhatLinksHere » QbasicFAQ_Limits » ASCII » CPU cycles » CompareCppClxWithCppVcl » CppCompileError » NewPages » cache » UNIX » OOP » BeginnersGuideToCSharp
Displaying differences between revision 5 and the latest revision


= 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 ==

Introduction[br]
Chapter 1: Introduction to programming in C#

[anchor:Intro]
== 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 [[OOP | 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.

[hr]

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.

[anchor:Chap1]
== 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.

[code]
using System;

namespace MyProgram
{
class HelloWorldProgram
{
public static void Main()
{
Console.WriteLine("Hello, World!");
}
}
}
[/code]

We will now explain each section of the program.

[code]using System;[/code]

This lets you use the classes in the namespace System.

[code]namespace MyProgram[/code]

The namespace for your Hello World program. This is similar to a package in Java. Namespaces are useful for organizing classes.

[code]class HelloWorldProgram[/code]

This is the main class of you application. All methods, fields, and properties must be contained in a class.

[code]public static void Main()[/code]

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.

[code]Console.WriteLine("Hello, World!");[/code]

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 [tt]using System;[/tt] 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: [tt]System.Console.WriteLine("Hello, World!");[/tt].


[hr]

Someone please continue this Beginner's Guide.



last edited (December 24, 2006) by bilderbikkel, Number of views: 22820, Current Rev: 6 (Diff)

[Edit this page]  [Page history]  [What links here]  [Discuss this topic]  [Printer Friendly]  
© 1996-2008 Community Networks Ltd. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Site Management by Lars Hagelin at Kontantkort.se.