Sunwen Tutorial ---- C # advanced
(zero)
Mrfat@china.com
Written in front
Before writing these articles, I didn't know anything about C #. I only heard some from the predecessors, saying that he was very like Java. Because I have been watching Java this time, what is the church, I can only blame me too Stupid :), actually I still don't have a chance to practice), so I really want to change the taste. In fact, I have heard of C #, I want to see this stuff, just on the M $ website, .NET Dongdong has more than 100 megaby! It's afraid, let alone all download, ask me a whole phone card? Fortunately, a friend will download .net download. Net. I took the hard drive and I ran over to copy it. A setup.exe, there is a 106M of the foot. So, I have to thank this friend, but there is no helping, there is no article.
When I wrote this article, I am afraid, afraid that my level is not enough, there are too many mistakes, and others are smashed. In the process of writing, I found that it is still more smooth, because these is a lot of pictures with the original Java. And many predecessors have a deep study. However, because the level is limited, the mistake is inevitable, if everyone finds any mistakes, I still hope that I am grateful! My mail: mrfat @ The younger brother is here!
The following article applies to those who have some Java / C programming experience. If there is Java programming experience, it is better, because I have contracted C # with the Java in many places. If you don't have any programming experience, you can Go to the homepage of OICQ to find another series of C # tutorials, that may be more suitable for you.
There is also because the following article is written in the idle time, more nonsense, everyone should not vomit blood @ # $% ^ & *! Ok, let's get started!
Sunwen Tutorial ---- C # advanced
(One)
Mrfat@china.com
Hello everyone, I am the Sunwen of Wuhan, I will come back. Everyone in May 1st, Sunwen has to fight in the bedroom, oh. Today, I want to tell you that everyone has heard of a long time, and it is full of mind: C #.
Today, I just came to M $ .Net development kit, from the m $ website, there is 106m, so Sunwen naturally has no money to go to him. Talk to 6:00 this morning ..... Next: Enter the topic, idiot! Another pair of shoes fly, this is the third pair!) Yes, I will start now!
When I got the reference, I saw that this is Java! It is indeed, like the outside world, on the surface, C # and Java very like, so that a person who knows Java can quickly master C # Structure. The implementation of its internal implementation, then I am not very clear, I can only make progress with everyone in my study, I hope everyone will pay more!
Ok, in order to give everyone a clearer feeling, I will first give you an example, nature is HelloWorld (old soil!).
000: // HelloWorld / Hello1.cs
001: public class hello1
002: {
003: public static void main ()
004: {
005: System.Console.writeline ("Hello, World!");
006:}
007:}
Its output result is:
Hello, World!
Some friends have discovered that Java! Only change system.out.prinln () to system.console.writeline ()!
Let's analyze this program, the entire program consists of a public static void main () method, which is inevitable, the execution code is inside .stem.console.writeline ("Hello, World!" The role of this statement is to print a line of hello, world !. It's very simple!
Let's take another:
000: // HelloWorld / Hello2.cs
001: using system;
002:
003: Public class Hello2
004: {
005: public static void main ()
006: {
007: console.writeline ("Hello, World!");
008:}
009:}
This program uses a using, in fact, it is equal to the Import in Java, is the meaning of a packet. When you reference this package, don't point out the full name, as long as console.writeline () Yes, you don't have to use system.console.writeline () so long, omitted SYSTEM.
Example 3, as shown in the following, how to display the parameters of the command line
000: // HelloWorld / Hello3.cs
001: using system;
002:
003: Public Class Hello3
004: {
005: public static void main (string [] args)
006: {
007: console.writeline ("Hello, World!");
008: console.writeline ("You Entered The Following {0} Command Line Arguments:", Args.Length);
009: for (int i = 0; i 010: { 011: console.writeLine ("{0}", args [i]); 012:} 013:} 014:} It can be seen that the string array args refers to the input parameters. Because it is a String class, there is a Length method, so there is args.length to access its length. Then use a for loop to display them. As for the loop, most of the syntax of C is used. Example 4, if you want a return value, you can write like this, use Return: 000: // HelloWorld / Hello4.cs 001: using system; 002: 003: Public Class Hello4 004: { 005: public static int main (String [] ARGS) 006: { 007: console.writeline ("Hello, World!"); 008: Return 0; 009:} 010:} Very simple! Oh! In the case of people who understand C or Java, I understand that if it is VB or VBS, there are some difficulties. Stay! Ok, after reading a simple example, let's go to the next lesson!