The XOR of C # and Visual Basic

Source: Internet
Author: User

C # is a high-level programming language, a safe, stable, simple, and elegant programming language that has many similarities to Visual Basic, as well as a lot of different places. Our blog today is based on the principles of Learning C #, highlighting the similarities and differences between C # and Visual Basic. elaborated from several aspects separately. For reasons that are confined to space, we may be divided into several sections that are presented in the form of a few blogs. I hope that we all pay more attention, more valuable advice, we progress together! Let's get down to the chase-

          C #, like Visual Basic, is an object-oriented visual programming language. C # has been supported by its powerful operational capabilities, elegant grammatical style, innovative language features, and easy-to-use component-oriented programming. The preferred language for net development. Based on a better and more comprehensive study of C #, we equate C # with the Visual Basic language to compare the similarities and the similarity between them.            generate:          to speak a language, the first thing that can not be spared is the nature of its production. Although in terms of program design, the production of a language is not the play of the language, but it is also a part of the non-negligible. It is helpful for us to understand, learn and master the language by tracing its origin and its development. Here's a brief introduction.            First of all, visual Basic, or VB, is a software development tool in Windows-based operating system launched by Microsoft, USA is a powerful, high-level programming language. It can be said that Visual Basic is the most basic language in all programming languages, and many people may be dismissive of its learning. But because of the basics, it's learning to lay a good foundation for learning other programming languages later, and you'll find it less difficult to touch a new programming language. (later I will write an article about the importance of basic learning of VB for learning other programming languages, not repeat here)            again c#,c# read C sharp, It was a new programming language released by Microsoft in 2000 and was developed primarily by Andershejlsberg and was the first component-oriented programming language. It is derived from C and C + +, and on the basis of C and C + + some powerful features, but also removed some of their complex features, integrated VB simple visualization and C + + high operating efficiency.                     Take an example:          This is a show " Welcome to the C # learning! " The program, shown below is thisThe same program is displayed in C # and the Code and interface in VisualBasic. Let's take a look at each of them.                    This is the running form interface for C #           &NBSP;&N Bsp [Csharp] using System;  using System.Collections.Generic;  using System.Linq;  using System.Text;    namespace My example Hello_world  {     class program      {         static void Main (string[] args)          {             Console.WriteLine ("Welcome to the C # learning!!!");         }     }  }            This is the code part of C # to implement the above interface                 This is the VB run form interface     &NBSP;&NBSP;[VB]  private Sub F Orm_load ()      Me.autoredraw = True      FontSize = +      FontBold = True            Print "Welcome to the C # learning!!!"             end Sub    &NB Sp             &NBSP;&NBSP;[VB]  private Sub form_click ()      FontSize = 1 8      FontBold = True            Print "Welcome to the C # learning!!!"             end Sub            This is the code part of VB to implement the above interface. People who have contacted VB know that this is done in two different ways to achieve the above interface. One is using the Click event, and one is the Form_Load event.                 through the comparison of the above pictures, we can clearly see the difference between C # and VB. The above example code is very simple, so the effect may not be particularly obvious. Compared to C # and VB, actually the implementation of this example is a code thing. In VB, you can add a control, add a Label control, the code can be written directly [VB]  <span >      label1.caption = "Welcome to the C # Lear Ning!!! " </span>          C # code, the fundamental, in fact, is a word, take this line of code alone, as follows: [CSharp]  < span >      console.writeline ("Welcome to the C # learning!!!"); </span>            This is good, the VB line of code and C # code comparison, you will find that they are really a bit like, but not the same. First look at the VB code, its code means: Label1 (this control) of the caption (title) is "Welcome to the C # learning!!!"; C # code, which means: the WriteLine (method) of the console (console Class) displays the text line "Welcome to the C # learning!!!". is the display of text, the method is very different: VB has an equal sign, in C #, the equal sign is the meaning of the assignment, the double equals "=" is the same as vb "=" meaning; and in C # WriteLine methods enclose the lines of text to be represented, and note that there is a semicolon at the end of the line of code, that is, ";". After a lot of exposure to C #, you will find that in C # code, a lot of code is followed by a semicolon-";", as in the following code: [CSharp]  using System;  using System.Collections.Generic;  using System.Linq;  using System.Text;    namespace My Example 1  {     class program      {     &nbs P   static void Main (string[] args)          {             for (int i = 0; i < i++)              {         &NBSP ;       Console.Write ("Please enter a statement (enter end):");          &nbsp       String s = Console.ReadLine ();                  if (s = = "End")            &NB Sp     {                     break;      &NB Sp          }                  Console.WriteLine ("You entered Word: "+ S");              {        }     }  }             After a large amount of exposure to C #, you will find a line of code followed by a semicolon, in the C # code language block with { }, with no semicolon at the end. This with the depth of learning C # and the increase in the amount of code, will be a little bit of the law.        Comment method: [VB]    [csharp]  //This is the C # programming code  using System;              //Import the System namespace  using System.Collections.Generic;  using System.Linq;  using System.Text;    namespace My example Hello_world    /Declaration of LifeNamespaces My example Hello_world  {     class program              //declaring the program class      {         static void Main (string[] args)    //Program entry point, Main return type is VO ID          {             Console.WriteLine ("Welcome to the C # learning!!! ");    //Console Class WriteLine () method is used to display output results         }     }  }    & nbsp     This is the code comment method for C #  [vb] private Sub Form_Load ()      Me.autoredraw = True    &n Bsp       FontSize = 18:rem Set Font size      FontBold = True:rem font bold      &nbs p;     Print "Welcome to the C # learning!!! ": Rem   Screen display content        end Sub   [vb] private Sub Form_Load ()    &N Bsp Me.autoredraw = True      &NBSP;&NBSP;&NBSP   FontSize =     ' Set font size      FontBold = True   ' font bold        &NB sp;    Print "Welcome to the C # learning!!! "     " screen display        end Sub              This is VB Code comment method.           C # Annotation methods more commonly used is to add a double slash after the code, that is, "//", the above picture has been done very well, of course, C # annotation method is not just one, the double slash is used for single-line comments, two lines of comments with the "/* ....*/”。 where//is a code comment;/* This is a code comment */. Not only that, but the following table describes more annotation methods, which are interesting to look at.         &NBSP;VB shows two different methods of code commenting. People who have studied VB know that there are two methods of annotation in VB (for the moment I only know these two methods), one is single quotation marks, add the English state of the single quotation mark after the code, and the other REM annotation, that is, add a colon after the code, plus REM, annotated. Relatively speaking, the first method of annotation is more common, but also more commonly used.

C # and Visual Basic are different

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.