The----of the Sunwen Tutorial C # advanced 1

Source: Internet
Author: User
Tags command line
Tutorial Sunwen Tutorial----C # Advanced
(0)
Mrfat@china.com
It's written in front of you.

Before I wrote these articles, I knew nothing about C #. Only heard from the seniors, said he is very much like Java. Because I have been looking at Java this period of time, the results of what the hall did not see (can only blame me too stupid:), in fact, I think there is no opportunity to practice), so I would like to change the taste. In fact, I heard of C # , want to take a look at this dongdong, just on M$ 's website a look,. NET Dongdong to more than 100 trillion! Look at the fear, not to mention all the download down, I want to charge a whole phone card? Luckily, a friend of mine first put. NET download down, I took the hard drive ran over the handcuffs. A SETUP.EXE, full of 106M. So, I would like to thank this friend, Ken, without his help, there is no article below.

Writing this article, I was a little scared, afraid of my level is not enough, mistakes are too much to be scolded by others. In the process of writing, the discovery is relatively smooth, because these with the original Java has a lot of similarities. and Java, many predecessors have very deep research. However, due to my limited level, mistakes are unavoidable , if you find anything wrong, also hope to correct, in the next grateful! My mail:mrfat@china.com. My brother thanked him first!

The following articles apply to people with some java/c++ programming experience, which is even better if you have Java programming experience, because I compare C # with Java in many places. If you don't have any programming experience, you can go to the community of Oicq's home page to find another series of C # tutorials, That might be better for you.

There is because the following article is in the idle time to write, more nonsense, we have seen don't spit blood yo @#$%^&*! good, the following start!

The----of the Sunwen Tutorial C # Advanced
A
Mrfat@china.com
Hello everybody, I am Wuhan Hua Division's Sunwen, I came back again. 51 Everyone has gone, Sunwen also to fight in the bedroom, whining. Today, I would like to tell you about a long time, but also full of God's Secret language: C #.

I just got a m$ from a friend today. NET development package, from M$ 's website up and down, there are 106M, so Sunwen naturally have no money to go under him. Say Six O ' Day this morning ... (Stage: Get to the point, fool!) Another pair of shoes flew up, this is the third pair! Yes, I'll get started!

Just get the reference of C #, I look, this is simply Java! Indeed, as the outside world says, on the surface, C # and Java are very much like, so that a Java-literate person can quickly grasp the structure of C #. To its internal implementation mechanism, then I am not very clear, can only with everyone in the study of common progress , I hope everyone will join us!

Well, in order to give you a clearer feeling, I first give you an example, nature is HelloWorld (old-fashioned!).

M://Helloworld\hello1.cs
001:public class Hello1
002: {
003:public static void Main ()
004: {
005:system.console.writeline ("Hello, world!");
006:}
007:}
Its output results are:

Hello, world!.

Some friends have found, is java! just System.out.prinln () changed to System.Console.WriteLine () Bale!

Let's analyze This program, which consists of a public class (class) that must have a public static void Main () that executes the code. System.Console.WriteLine ("Hello, world!") The purpose of this statement is to print a row of hello,world! to the console (console). It's simple!

Here's another one:

M://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, which refers to the meaning of a package. When this package is referenced, the console class in the package does not point to the full name, as long as Console.WriteLine () is OK, You don't have to use System.Console.WriteLine () so long to omit system.

For example, the following shows how to display the parameters of the command line

M://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 < args.) Length; i++)
010: {
011:console.writeline ("{0}", Args[i]);
012:}
013:}
014:}
As you can see, the string array args refers to the input parameters. Because it is a string class, so there is a length method, so you can have args.length to access its lengths. And then use a for loop to show them. As for the cycle, most of these things follow the syntax of C. .

For example, if you want a return value, you can write it as follows:

M://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! For people who know C or Java, it is better to understand, if it is VB or VBS users, there are some difficulties. Stay!

Well, after reading the simple example, let's go to the next lesson!

Next page


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.