FreshNova - Home

Friday 30th of July 2010

Home C# Tutorials C# Getting Started
C# Getting Started PDF Print E-mail
Written by Talha Kalim   
Wednesday, 25 February 2009 20:19

Well knowing that there are many tutorials out there that will be able to help you with basic C# coding, I am writing this tutorial as a precursor to the C# client server programming tutorial. This tutorials will be followed by the C# events, delgates, and threading tutorials which we will be using later on in our client server programming tutorials.

Lets start with a simple hello world program which containd some basic constructs you will find in a C# program.The program may not really make much sense but I hope it gets through with the concepts. I am obviously going to assume here that you have some prior knowledge of object orientated programming concepts.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// lets just import sum packages we may need
using System;
 
public class Hello
{
   public static void Main()
   {
	//lets define an object of the class below
        SomeClass nothing = new SomeClass();
	SomeClass freshnova = new SomeClass(1, "FreshNova");
 
	// lets define some useless arrays and variables
	int number=0;
	String name = "Talha";
	String[] details={"Talha Kalim", "C# Getting Started"};
	int[] numbers= {1,2,3,4,5,5,7};
	// Naaa lets use a loop to initialize that
	for (int i =0; i<5; i++)
	{
 	   //just multiplying index by ten and putting in array
	   numbers[i]=i*10;
	}
	//just writing some text to the console
	Console.WriteLine("Hello, World!");
	//lets read some text form console and write to console
	Console.WriteLine("Please enter some text:");
	String input=Console.ReadLine();
	Console.WriteLine(input);
   }
}
public class SomeClass
{
   // Some private fields
   private int number;
   private String name;
 
   // Public property to get and change the value of private fields
   public int Number
    {
        get { return number; }
        set { number = value; }
    }
 
   //a simple consructor
   public SomeClass()
   {
      	// lets intialize the variables
	number=0;
	name="freshnova";
   }
 
   //a more useful consructor
   public SomeClass(int number, String name)
   {
      	// lets intialize the variables
	this.number=number;
	this.name=name;
   }
}

 

Well I suppose thats the most basic stuff that you have in any C# class. I will obviously define any concepts that are introduced later. I hope this is enough to brush some of the basics. Please do search for more details on concepts that are not clear, or just post a comment and I will try my best to help you out. Please provide us with feedback on how to improve and well if there are any discrepancies in the code above, please do let me know, so I can fix it. After all we all make mistakes, and we are ways learning...

 

Comments

avatar yll
0
 
 
[url=http://www.mbt-zapatos-2010.com][b]Mbt zapatos[/b][/url]como una tormenta se extendió por Europa y el mundo.[url=http://www.mbt-zapatos-2010.com/free-shipping-m bts-c-272.html][b]Mbt zapatos[/b][/url]cómo tener tanto poder? Según la investigación,[url=http://www.mbt-zapatos-2010.com/men-mbt-shoes-c -242.html][b]Mbt zapatos[/b][/url]no sólo su propio estilo de diseño único, sino también porque hay magia buena forma física, así[url=http://www.mbt-zapatos-2010.com/women-mbt-shoes-c -240.html][b]Mbt zapatos[/b][/url]no es coincidencia que es tan popular. Esta es una forma de cambio histórico[url=http://www.mbtzapatos2010.com/mens-mbt-zapato s-c-238_246_247.html][b]Mbt zapatos[/b][/url]son.
Name *
Email (For verification & Replies)
Code   
ChronoComments by Joomla Professional Solutions
Submit Comment
Cancel
Name *
Email (For verification & Replies)
Code   
ChronoComments by Joomla Professional Solutions
Submit Comment
Last Updated on Thursday, 26 February 2009 00:38
 

Archive

 

Categories


Copyright © 2009 FreshNova, by Talha Kalim and Waleed Al-Bahrawy