C # learning basic knowledge

Source: Internet
Author: User

The basic data type of. C # is fixed and does not change. It is different from C ++. Integer types are usually faster than smaller types, because the CPU has been optimized for integer types and memory alignment exists .. C # to convert A char to an ASCII equivalent, it must be forcibly converted to an int. For example: (int) 'A'. to convert A number to A char, it must be forcibly converted, example: (char) 65 .. C # switch case statement (jump by string ). [Csharp] view plaincopycase 1: fun1 (); // It cannot be executed downward, unless case 1: The last is an empty statement. To execute downward, use goto case 2; case 2: fun2 ();. C # requires that if can only accept boolean values (only true and false ).. C # all variables must be assigned a value before use. Otherwise, they cannot be used. For example, int a; System. Console. WriteLine ("a: {0}", a); an error is returned .. C # Boolean variables can only be true or false, and there is no implicit conversion .. C # It does not have the header file concept and does not require methods to be declared before definition. It does not support putting method declarations in header files .. The default member variable of C # class is private .. C # The basic data type (int, char, etc.) is in the stack space, and the object is the reference type. In the heap space, new and C # need to be used to manage all the memory through the garbage collection system, the delete operator does not exist .. C # static methods are similar to global methods. They can be called without object instances, but the scope is still in the class. For static methods, class names are like namespaces. Static methods cannot directly access non-static members. An object must be instantiated first .. In C #, class inheritance is not private or protected. The derived class inherits all the members of the base class, including member variables and methods. For example, publicclass ListBox: Control colon is read as "derived from ".. C # The Implementation of Virtual methods must explicitly use the override keyword to redefine the method declaration of virtual methods.

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.