CyberArmy University | Open Source Institute | CyberArmy Intelligence & Security | CyberArmy Services & Projects

[Library Index]

[View category: Programming] [Discuss Article]

Introduction to C Sharp

Article is yet to be rated
Author:      DarkJester
Submitted:      28-Apr-2007 19:41:03
Imported From:      The CyberArmy University (original author: DarkJester)


Getting a hang of the C# Programming Language
::__Introduction to C#__::
::Getting a hang of the C# Programming Language::
---
With the introduction of Microsoft's .NET platform came a handy little language which many people had never seen before. C# became a new popular programming language. With Microsoft's Visual Studio came a nice easy user interface helping people get off the ground with this language. While many may say programming interfaces like this are a disgrace to the programming world, that is not true at all. For C#, C Sharp(like the musical thing which I don't know anything about other then its name), it was a hit. Many people over the years have taken up to learning Java and when many universities took it over as thier main beginners programming language, due to it heavy use of OOP, Object Oriented Programming, this further helped the C# community. C# in itself has many qualities making it a near identical language to Java, but it leave much more for the programmer. Unlike Java, C# is not used in applets, nor is it open source. However C# takes away the sluggishness of programming that Java seems to have when you are running programs or compiling. C# is the beginning of something great.

While many people may take a disliking to MS, Microsoft (which is entirely too long for me to type anymore), certain things keep you coming back for more. To start off into some programming, without boring you to death with too much text, you need to know that the .NET framework makes things different from Java so please bare with me even if you are not used to the syntax. One of the "handy" features of C# is you get to use namespaces, but you dont have to for this introduction.

^using System;
class HelloWorld { // You love me already don't you?
static void main(string[] args) {
Console.WriteLine("Hello World!");
}<br />
}^

As you may or may not have already noticed, if you are a Java user, you dont need to declare stuff as public, private, or protected in simple programs such as this. Another thing you will notice is we don't use ~~#FF0000:System.out.println~~ which is the standard output function in Java. Other then that it should look pretty simple. We use the system class which is already made for us in the framework, we define a class named HelloWorld, we make the main function which is ~~#FF0000:static~~ and our method returns nothing so we ~~#FF0000:void~~ that out. Finally we write to the console ~~#00FF00:Hello World!~~. Pretty simple right? I like to think so.

When you are working in C# always remeber to save the file as .cs which is the file extension used for C#. I am using Microsoft Visual Studio .NET 2003 for this tutorial so remember to always check your specific compiler for changes.

For the Java writers I can write stuff with the ~~#FF0000:public~~ and ~~#FF0000:private~~ types also, but it is not always necessary in short programs like this. If you wish to add them just due to habbit or if you are used to using Javadoc or whatnot you can add them. For more understanding of the C# specifics, if you are from another similar type of programming background, you should take a look at MSDN, see the link at the bottom of this article.

C# has many features, some of which are reflected in Java or other languages in the .NET platform. You cannot go wrong when you are working for a mainly MicroSoft Windows audience if you are using a MicroSoft programming language. Hope you enjoyed the article.

__Links and Sources__:

MicroSoft
- Website : http://www.microsoft.com
- MSDN : http://msdn.microsoft.com

C#
- Documentation : http://msdn.microsoft.com/vcsharp/programming/default.aspx

This article was originally published by CyberArmy.net in the CyberArmy Library.

You must be logged in to vote on an article

About Us | Privacy Policy | Mission Statement | Help