C # differences with C and OC,

Source: Internet
Author: User
Tags switch case

C # differences with C and OC,

Actually, those familiar with these languages know that these languages are completely incomparable.

Due to work needs, it is necessary to revisit the C # Language recently, which will inevitably be affected by the basic knowledge of C and OC.

This article is a learning note for me. It is dedicated to my friends who have C/OC basics and need to continue learning C.


Blog address: http://blog.csdn.net/duzixi


We will continue to update the data in the future. You are welcome to make additional amendments (Last updated on: 2014.11.6)


1st basics: constant variable operator expression statement ***** C # provides more basic types and finer Division
* *** C # The bool type is the bool type, which is strictly different from the integer type.
* ***** C # the Console inputs are all callback streams. To obtain other types, use the Parse method to convert int a = int. Parse (Console. Readline ());
* ***** C # statements and implementations are not separated. C # Essence (Third edition) p.121

2nd about the branch structure ***** C # The switch expression value in switch case can also be a string type
3rd circular structure array
* ***** The essence of C #'s array is System. Array. It is the abstract base type of all array types. It must be instantiated. When declaring an array, square brackets ([]) must follow the type, not the identifier, and the array size is not part of its type. For example: bool [], byte [], int [], float [], double [], string [],
* ***** C # the two-dimensional array and the array (staggered array) are two-dimensional array definitions: string [,] names; staggered array (jarged array ): byte [] [] scores; http://msdn.microsoft.com/zh-cn/library/aa288453 (v = vs.71 ). aspx
* ***** Arrays in C # can be directly assigned values, but they cannot be directly added or subtracted like C.
4th enumeration and struct *** C # enumeration is not a simple plastic constant http://msdn.microsoft.com/zh-cn/library/cc138362.aspx
* ***** The structure in C # is more powerful and flexible, and can contain methods directly.
* C # The struct member variable type modifiers must be public structures that can implement interfaces, but they cannot inherit from another structure. Therefore, the structure member cannot be declared as protected. Http://msdn.microsoft.com/zh-cn/library/ah19swz4.aspx
5th talk about the reference type string ***** C # There is a unique reference type, is the value type obtained by packing will be thrown into the heap after the http://msdn.microsoft.com/zh-cn/library/yz2be5wk.aspx
* ***** The C # string is a class.
6th lecture class
* *** C # class includes methods, attributes, fields, events, delegation, and nested internal classes. For example, http://msdn.microsoft.com/zh-cn/library/ms173113.aspxa class can contain the following descriptions:
Constructor)
Destructor
Constant (Const)
Field)
Method)
Property)
Indexers)
Operator)
Event)
Delegate)
Class)
Interface)
Structure (Struct)
* ***** C # has rich modifiers and can be used to modify many things. 1. public protected private internal2. controlling the effective range and permissions: static const3. declaring the function parameter: ref out params4.: virtualhttp: // msdn.microsoft.com/zh-cn/library/9fkccyh4.aspx
* ***** Access permission

Option Classes that can be declared directly in the namespace in other option classes are not nested and can be public or internal. By default, the option class is internal.

Class Members, including nested option classes, which can be public, protected internal, protected, internal, or private. By default, Members are dedicated.

Http://msdn.microsoft.com/zh-cn/library/0b0thckt.aspx
* ***** C # attributes can be created only on the basis of fields. The attribute starts with uppercase letters.
* ***** C # functions can only be defined in the class
* ***** C # There is a seal class
* *** C # A base statement constructor can use the base keyword to call a base class constructor. Http://msdn.microsoft.com/zh-cn/library/ms173115.aspx
7th method (function)
* ***** The C # method can only appear in the class and struct.
* C # contains the concept of method signature. method name parameters and parameter type http://msdn.microsoft.com/zh-cn/library/ms173114.aspx
* ***** C # function parameters are modifier ref: reference parameter out: output parameter params: one-dimensional array
* ***** C # release memory resources through destructor
* *** C # virtual method http://msdn.microsoft.com/zh-cn/library/9fkccyh4.aspx
* *** C # is called a method signature.

8th object-oriented ***** C # two classes with inheritance relationships are called the base class and the derived class. When the base class declares the method as virtual, A derived class can use its own implementation to override this method. Http://msdn.microsoft.com/zh-cn/library/ms173149.aspx? SentenceGu = 431ef25c6bea78755c146f18e5e213ae # mt9
* ***** C # Is polymorphism and has multiple implementation methods.
9th static and abstract classes
* ***** Static classes and abstract classes are unique to C #

10th the interface and the generic *** C # interface are similar to the OC protocol.
Http://blog.csdn.net/byondocean/article/details/6871881

11th talk about the collection of * C # Set is divided into generic set and non generic set http://msdn.microsoft.com/zh-cn/library/yz2be5wk.aspx

12th delegation and event ***** C # delegation are similar to C function pointers, but the type security has been encapsulated into a Type
* ***** The observer design mode of C # is implemented by delegation and events.

13th reflection ***** reflection is unique to C #


In general, I feel that the modifier C # is rich and the modifier content is still being organized.

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.