For C # (sharp) To be honest, I was just beginning to teach myself, sophomore my major is actually Java, but C # I will not fall, starting today to embark on the road of self-learning C #!
One: Understanding C # and. NET
. Net/dotnet: generally refers to the. NET Framework framework. is a platform, a technology.
C #: A programming language that can be developed based on. NET platform applications.
These two relationships complement each other, make an analogy. NET is like the body of our bodies, and C # is like our brains, and we use a series of instructions sent by our brains to make our bodies perform a series of actions. In contrast, Java,java is both a technology and a language.
II: Project creation in C #
Install Visual Studio2010 When you create a C # project (we learned that Xiaonei has 2010 and 2013 versions, but for computer reasons I use 2010) New C # project I select "Console Application" (because I am a beginner, It reminds me of the days when I started to learn C language. Then write a name for my project "Firstprogram" Click OK after you see my "Firstprogram" project in the Solution window, and then open "Program.cs" to start My Code,
<pre class= "CSharp" name= "code" >using System; Using System.Collections.Generic; Using System.Linq; Using System.Text; Namespace Firstprogram { class program { static void Main (string[] args) { //Add code here } } }
VS has already written a part for us, and in contrast to C, #include<> becomes the using system, but the meaning is similar to representing the predefined elements of the system, so that the elements can be used freely in their own programs. After a series of references there is a "namespace firstprogram{}" namespace that defines a namespace called Firstprogram, the role of the namespace is good for the site, easy to centralize management, C # is a fully object-oriented language, All object type definitions must be defined under a namespace, as if a person (method) belongs to a city (type), and the city belongs to a province (namespace); After the province (namespace), the City (class program) defines a class called program. Class Below is the main () method, in C # program execution always starts from main (), so a program does not allow two or more than two main () methods, learn C may know this, but note that the main () method must be included in a class.
Three: Write a simple output program
The input and output of the program in C # console is done by the console, which is a class defined by the system in the namespace, which is why you should write the using system at the beginning ... In the console, input, Output method Console.ReadLine () and Console.WriteLine () (line break) or Console.Write () (no wrapping) below an example output "Happy National Day!!!" ”
<pre class= "CSharp" name= "code" >using System; Using System.Collections.Generic; Using System.Linq; Using System.Text; Namespace Firstprogram { class program { static void Main (string[] args) { Console.WriteLine ("Happy National Day!!! "); } } }
The above is the C # Learning Diary 01--Novice Road content, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!