. NET 0 Basics 01: Opening and CSHARP the structure of programs and solutions

Source: Internet
Author: User

One: Why Choose C #

Everyone has a dream, some people's dream is: Become a programmer. The best course (www.zuikc.com), "0 basic C # Primer", is an attempt to help us achieve this dream.

Perhaps you want to ask: I base very poor how to do? The top 0 Basic C # Primer assumes that you have never written a single line of programs. Of course, we also believe that this series of study for the university undergraduate computer, but the beginning of the programmer in this industry, the students have a great help.

Now, we're going to
Why Choose C #?

Why Choose C # as the first language you become a programmer, we come down here for 3 reasons:

? First, C # is a very good object-oriented programming language.
Anyone interested in coding must have heard of the concept of "object-oriented Programming", C # is the birth of this, it is naturally object-oriented. Therefore, since "object-oriented programming" is the mainstream of the current IT industry, we choose C # without deviating from the mainstream direction.

? Second, C # is a development language currently being pushed by Microsoft.
C # (read C sharp), formerly cool (cool Enough), it was released on June 26, 2000. It's only been more than 10 years, but if we're using Microsoft's technology to develop general applications on the Windows platform, it's hard to imagine what language is more appropriate for C #.

? Finally, after years of development, the C # language is perfect for getting started
C # syntax is simple and easy to get started. It satisfies our desire to become a programmer quickly, and our initial practical programming example, an interesting "mouse-playing" game, using C #, can quickly make us feel that we are writing useful code, rather than learning all the time, until one day to write useful code.

II: What programs can be developed using CSHARP

Let's take a look at what programs can be developed using C #:

First, you can use C # to develop a traditional Windows Forms program. such as QQ, Storm audio, such as word, Visual studio, and so on, they are form programs, and no matter what they are developed, but now we can use C # for development.

Second, the use of C # can also develop Web applications, and C # has become the most preferred and unique language for Web development using Microsoft technologies. Vb.net,asp, that is not the mainstream, even the non-mainstream of the fast count.

In addition, yes, a cool C # application, which is the development of the Windows Phone platform. With C #, we can easily develop on the most popular mobile platforms, including tablets, and we can upload our app to Microsoft's App Store and let someone else use your program.

In addition, we can play the game on the above platform development, this is a content branch, all of it is listed separately, because we love the coding is to a large extent, we are game enthusiasts, and using C # can let us develop their own games on many platforms. Now, with some third-party frameworks, we can use C # to develop games and deploy them on platforms such as iOS and Android.

Using C #, we can do 90% of the world's things. So the rest of the 10%, um, this, wait till we get started.

Three: What tools are used to develop C # programs

What tools do you use to develop CSHARP programs? The preferred course is Microsoft's visual Studio, of course, if we have to pursue a maverick, of course, you can also use Notepad to write code, and then use the. NET framework commands to compile into an executable program.

The industry also has several other tools to develop C #, but none of them has become mainstream. As a beginner, we'd better use visual Studio, the current stable version is 2013 (note that the instructional video is 2012, but this does not affect our learning).

Another suggestion is that we better use the English version, the use of the Chinese version, the beginning may be easier to start, but not conducive to our growth as a professional developer, because once the coding experience is growing, in the debugging process, will inevitably appear some abnormal information, most of the exception we can be found in the Chinese site , but some of the more difficult exceptions are often English websites can provide effective help, if we use English version, then the English exception information can help us to search for this information.

Incidentally, if your English is good, in the coding process encountered problems to solve their own, you can go to stackoverflow.com this site for help, this is the most prosperous on the Earth on the code question and answer site, generally speaking, how difficult the problem can be quickly answered on the site. Chinese-type website also has csdn, blog garden and so on.

Visual Studio's official website in Microsoft is:
Http://www.microsoft.com/visualstudio/chs/downloads

Four: How to write a CSharp program needs to have what basis

OK, let's look at the basics of writing a program, see 4 points:

Next, we'll let you quickly go through the above 4 aspects, starting with the Hello World Console program, and we will be familiar with these points of knowledge when this course is completed.

On the last point: Data types, operators, and control flows, we want to emphasize that we want you to be involved in the process of coding a task, and we'll talk about it if it involves a bit of knowledge. A lot of books or courses, a large amount of grammar and basic knowledge, often let us lose the interest in learning, we are here to change a way of thinking, that is, directly write the program, by writing code, to naturally grasp the basic knowledge. For example, in order to speak these basic knowledge, we have to write two programs, one is very classic Hello world, and then we have to write a very simple game of mice, hope that through this game of mice to build this confidence: Yes, even if I only have limited knowledge of C #, I can also write a more interesting program.

V: Structure of CSHARP Program and solution

See how we can create one of the simplest applications.

First, learn how to create a new C # program, first, open vs, then select New->project:

The following UI will appear at this time:

In, the red numerals 1, 2, 3, 4, 5 respectively refer to:

1, refers to the type of application we want to create (also known as the project type, so we have just the operation is: New->projcet), here we choose is we want to create a Windows program;

2, which means we choose to create a console program (that is, the project type: Console application), that is, the console application;

3, refers to the name of the application (that is, the name of the current console application), here, I personally think it may be "name" into "Project name" more conducive to beginners to identify the concept;

4, is the path of the program we are going to create;

5, remember that each project will belong to a solution, where we enter the name of the solution. When we create this console application (project), VS will automatically create a solution for us. The relationship between them is that the project belongs to the solution, and a solution can take multiple projects.

Click OK, vs will create this application for us, as follows:

Let's enter a line of code:

Console.WriteLine ("Hello world!");

(In the Red box), and then we run up, select the menu: "Debug->start without Debugging", of course, you can also use the shortcut key "Ctrl+f5":

The effect is as follows: Output "Hello world!" under the console of Windows :

VI: How the solution and engineering are organized

Above, we've got "Hello world" running in the quickest way, and now we need to look back and see how the entire application is organized.

Let's do this by right-clicking on the solution name and selecting Open Folder in File Explorer:

This time, the location of the solution on the hard disk will be opened,

In this, the most important is the red box of two entities, "MyFirstSolution.sln" represents our solution, and "Myfirstproject" stands for our console Application (project), now we double-click " Myfirstproject ", look inside the folder, and then compare it to the VS interface:

Along the arrows, we can find the file on the hard disk and the VS file one by one corresponding relationship:

Program.cs corresponds to Program.cs;

App. Config corresponds to App. config (application configuration file, without having to control it);

Myfirstproject.csproj corresponds to the project "Myfirstproject" in VS;

In addition to the arrows in the pointed, there is a red box, in the Red box under the folder, the application of our generated: MyFirstProject.exe. Open the console of Windows, drag the file to the console, and run it the same as we used the Debug->start without debugging in vs.

Step 1:

Step 2:

Seven: How applications are organized

We wrote the "Hello World" program and we went back to this interface:

We need to look at how the program itself is organized, that is, how we run the application, what it does throughout its life cycle, what the first line of code it executes, and what the last line of code is.

In response, we give the following conclusions:

1: Any C # application has a unique main function, which acts as an entry for the entire application;

2: In the 12th, 14 lines of code is equivalent to the entire application of the first line and the last line of code;

3: Complex applications, in fact, the 13 lines into more complex code;

Now, let's start with a slightly more complicated and somewhat interesting program: hitting mice, which is the first task of our course.

. NET 0 Basics 01: Opening and CSHARP the structure of programs and solutions

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.