Home Backend Development C#.Net Tutorial SUNWEN tutorial - C# advanced (1)

SUNWEN tutorial - C# advanced (1)

Dec 19, 2016 am 10:15 AM

Before writing these articles, I knew nothing about C#. I only heard some from my seniors, saying that it is very similar to Java. Because I have been looking at JAVA during this period, but I didn’t see the difference (I can only blame me Too stupid:), in fact, I think there is still no chance to practice), so I really want to change my taste. In fact, I heard about C# very early and wanted to take a look at this stuff. I just went to the M$ website to take a look. NET stuff costs more than 100 megabytes! I was scared when I saw it, not to mention that downloading it all would cost me a whole phone card? Fortunately, a friend of mine downloaded .NET first, and I took the hard drive and ran over to copy it. Here it comes. A SETUP.EXE is 106M in size. Therefore, I would like to express my special thanks to this friend KEN. Without his help, there would be no following article.

When I was writing this article, I I'm a little afraid that I'm not good enough, make too many mistakes, and get scolded by others. During the writing process, I found that it went relatively smoothly, because there are many similarities with the original JAVA. As for JAVA, many seniors have very good skills. In-depth research. However, due to my limited level, mistakes are inevitable. If you find any mistakes, I would like to correct them. I would be very grateful! My MAIL: mrfat@china.com. My brother is here first. Thanks!

The following article is suitable for people who have some JAVA/C++ programming experience. If you have JAVA programming experience, it would be better, because I compare C# with JAVA in many places. If you don’t have any If you have programming experience, you can go to the community on the OICQ homepage to find another series of C# tutorials, which may be more suitable for you.

Also, because the following article was written in my free time, there is a lot of nonsense, and everyone has read it Don't vomit blood @#$%^&*! Okay, let's get started!
Hello everyone, I am SUNWEN from Wuhan China Normal University, and I am back again. Everyone has left on May Day, but SUNWEN still has to fight hard in the dormitory, ugh. Today, what I want to tell you is a language that everyone has heard for a long time and is full of mystery: C#.

I just got M$’s .NET development package from a friend today. I downloaded it from M$’s website and it’s 106M, so SUNWEN naturally doesn’t have the money to download it. By the way, at six o’clock this morning... (Audience: Let’s get to the point, idiot! Another pair of leather shoes flew up, this is the third pair!) Yes, I’ll start right away!

When I first got the C# reference, I saw it, this is simply JAVA Well! Indeed, as the outside world says, on the surface, C# and JAVA are very similar, so that a person who knows JAVA can quickly grasp the structure of C#. As for its internal implementation mechanism, I don’t know much about it. , I can only make progress together with everyone in learning, and I hope everyone will support me!

Okay, in order to give you a clearer feeling, I will first give you an example, which is of course HelloWorld (old-fashioned!).

000: // HelloWorldHello1.cs
001: public class Hello1
002: {
003: public static void Main()
004: {
005: System.Console.WriteLine("Hello, World!");
006: }
007: }
The output result is:

Hello, World!

Some friends have discovered that it is JAVA! Just change System.out.PRinln() to System.Console.WriteLine() That’s it!

Let’s analyze this program. The entire program consists of a public class, which must have a public static void Main() method, and the execution code is inside. System.Console.WriteLine("Hello , World!") The function of this statement is to print a line of Hello, World! to the console (Console). It's very simple!

Here's another one:

000: // HelloWorldHello2.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 Using a using is actually equivalent to import in JAVA, which means referencing a package. After referencing this package, there is no need to indicate the full name of the Console class in this package, just Console.WriteLine(). , there is no need to use System.Console.WriteLine() for such a long time, System is omitted.

Example 3, the following shows how to display the parameters of the command line

000: // HelloWorldHello3.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: }
You can see that the string array args refers to the input parameters. Because it is a String class, it has a Length method , so you can use args.length to access its length. Then use a for loop to display them. As for loops, most of them follow the syntax of C.

Example 4, if you want a return value, you can like Write like this, use return:

000: // HelloWorldHello4.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: }
It's very simple! Haha! It looks better for people who know C or JAVA I understand, if you are a VB or VBS user, you will have some difficulties. Stay tuned!

Okay, after reading the simple example, let’s move on to the next lesson!

The above is the content of the SUNWEN tutorial - C# Advanced (1). For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Active Directory with C# Active Directory with C# Sep 03, 2024 pm 03:33 PM

Guide to Active Directory with C#. Here we discuss the introduction and how Active Directory works in C# along with the syntax and example.

C# Serialization C# Serialization Sep 03, 2024 pm 03:30 PM

Guide to C# Serialization. Here we discuss the introduction, steps of C# serialization object, working, and example respectively.

Random Number Generator in C# Random Number Generator in C# Sep 03, 2024 pm 03:34 PM

Guide to Random Number Generator in C#. Here we discuss how Random Number Generator work, concept of pseudo-random and secure numbers.

C# Data Grid View C# Data Grid View Sep 03, 2024 pm 03:32 PM

Guide to C# Data Grid View. Here we discuss the examples of how a data grid view can be loaded and exported from the SQL database or an excel file.

Factorial in C# Factorial in C# Sep 03, 2024 pm 03:34 PM

Guide to Factorial in C#. Here we discuss the introduction to factorial in c# along with different examples and code implementation.

Patterns in C# Patterns in C# Sep 03, 2024 pm 03:33 PM

Guide to Patterns in C#. Here we discuss the introduction and top 3 types of Patterns in C# along with its examples and code implementation.

Prime Numbers in C# Prime Numbers in C# Sep 03, 2024 pm 03:35 PM

Guide to Prime Numbers in C#. Here we discuss the introduction and examples of prime numbers in c# along with code implementation.

The difference between multithreading and asynchronous c# The difference between multithreading and asynchronous c# Apr 03, 2025 pm 02:57 PM

The difference between multithreading and asynchronous is that multithreading executes multiple threads at the same time, while asynchronously performs operations without blocking the current thread. Multithreading is used for compute-intensive tasks, while asynchronously is used for user interaction. The advantage of multi-threading is to improve computing performance, while the advantage of asynchronous is to not block UI threads. Choosing multithreading or asynchronous depends on the nature of the task: Computation-intensive tasks use multithreading, tasks that interact with external resources and need to keep UI responsiveness use asynchronous.

See all articles