Keyword of C,

Source: Internet
Author: User

Keyword of C,

Each language has a lot of keywords, and these keywords are also similar, but after all there are some differences. Some keywords are more familiar to you, but some keywords are not widely used or newly introduced, so you are not familiar with them. I usually encounter some keywords, and I feel a little unfamiliar. I usually understand and record the usage of these keywords that I don't understand. I think there should also be many people like me, so I will share my records with you. Please correct me more about tx!Access keywordsBase: used to access members of the base class in a derived class.

  • Call methods that have been overwritten by other methods on the base class

    1 public override void GetInfo () 2 {3 base. GetInfo (); // call the GetInfo Method 4 on the base class}

  • Specify the base class constructor applied when creating a derived class instance

    1 public MyDerived (): base () // call the constructor of the base class 2 {}

It is incorrect to use the base keyword in a static method.
Conversion keywordsExplicit: Used to declare user-defined explicit type conversion Operators

1 class MyType 2 {3 public static explicit operator MyType (int I) 4 {5 // Code 6 to convert from int to MyType} 7}

Explicit conversion operators must be called through type conversion

1 int I; 2 MyType x = (MyType) I; // the conversion from int to MyType requires type conversion.

If the conversion operation may cause exceptions or information loss, the explicit keyword is applied to mark it. Implicit: Used to declare User-Defined implicit conversion Operators

1 class MyType 2 {3 public static implicit operator int (MyType m) 4 {5 // code for converting from MyType to int type 6} 7}

1 MyType x; 2 int I = x; // implicitly calls the conversion operator from MyType to int type.

Implicit conversion can improve the readability of source code by eliminating unnecessary type conversion. Generally, when an implicit conversion is called, no exception is thrown and no information is lost. Otherwise, it should be marked as explicit.Method parameter keywordsIf ref or out is not specified when a method parameter is declared, the parameter has a value related to the method. This value can be changed in the method, but this change will not be retained when the program returns to the call process. Params: this parameter is used to specify a method parameter with a parameter when the number of parameters is variable. It is not allowed to introduce any other parameters after the params keyword in the method declaration, but can have other parameters before it. In addition, only one params keyword is allowed in the method declaration.

1 public static void UseParams (params int [] list) 2 {3 for (int I = 0; I <list. length; I ++) 4 {5 Console. writeLine (list [I]); 6} 7} 8 9 public static void Main () 10 {11 UseParams (1, 2, 3 ); 12 int [] myArray = new int [3] {10, 11, 12}; 13 UseParams (myArray); 14}

Ref and out allow the method to reference the variable passed to the method. When the program transfers to the call method, any changes made to the parameter in the method will be passed to the variable. The value of the ref parameter will be passed to the ref parameter, so it must be initialized first; otherwise, the value of the out parameter will not be passed to the out parameter, so it does not need to be initialized first, however, it must assign a value to the out parameter before returning the method. The property is not a variable and cannot be used as a ref/out parameter.


How should I learn C language?

Hello

Self-study of the following books

The original book "The C Programming Language" and "C Programming Language" is one of The designers of C Language Dennis M. ritchie and famous computer scientist Brian W. A typical book on C language, co-authored by Kernighan. The well-known "hello, World" Program was introduced for the first time by this book. Now, this program has become the first lesson for getting started with all programming languages. The original version 2nd was appropriately revised according to the ANSIC standard formulated in 1987, introducing the latest language format, and adding new examples through concise descriptions and typical examples, the author comprehensively, systematically, and accurately describes the features of C language and the basic programming methods. For computer practitioners, this book is a must-read reference book on programming languages.
"Expert C Programming" and "C Expert Programming" demonstrate the coding skills used by the best C programmers. They have opened up a chapter to introduce the basic knowledge of C ++.
The history, language features, statements, arrays, pointers, links, runtime, memory, and how to further learn about C ++ in the book are explained in detail and analyzed in depth. The book provides several dozen examples, which has very high practical value for C programmers.
The authors of C Traps and Pitfalls and C Traps and defects are based on a paper published at Bell's laboratory in 1985, expanded into a classic book of valuable value to C programmers based on your work experience. The starting point of writing this book is not to criticize the C language, but to help C programmers bypass the traps and obstacles in the programming process.
The book is divided into eight chapters, which analyze possible problems in C programming from the aspects of lexical analysis, syntax semantics, connection, library functions, pre-processor, and portability defects. At last, the author gives some practical suggestions in the chapter.
Pointers on C, C and pointer provides comprehensive resources related to C Programming and in-depth discussions. This book explores the basic knowledge and advanced features of pointers to help programmers integrate the powerful functions of pointers into their own programs. The book consists of 18 chapters covering almost all important C programming topics, including data, statements, operators and expressions, pointers, functions, arrays, strings, structures, and associations. The book provides a lot of programming skills and tips. Each chapter is followed by a very targeted exercise. The appendix provides some answers to the exercises.
The book C: A Reference Manual and C Reference Manual are divided into two parts, with 24 chapters in total. The first part discusses all the features of C language, including lexical, preprocessing, declaration, type, expression, statement, function, and other basic language features. The second part discusses the standard library of C language, which is described in detail based on their different functions. To help readers understand related concepts, this book provides many examples and explanations when discussing various aspects of the C language and its standard library. Exercise questions are also provided in the first chapter, and answers to the main exercises are given after the Book. The main purpose of these exercises is to help readers understand the basic mechanism and important details of C language, which does not involve complex programming techniques and problems.
C Primer Plus fully describes the concepts and knowledge of C programming. The book consists of 17 chapters. Chapter 1.2 provides the preparatory knowledge required for C programming. Chapter 5 to 15 describes the knowledge of C language, including data type, formatting input and output, operators, expressions, process control statements, functions, arrays and pointers, string operations, memory management, bit operations, and so on. The knowledge is applicable to C99 standards; in addition, Chapter 10th strengthens the discussion of pointers, and Chapter 12th introduces the concept of dynamic memory allocation, which is more suitable for readers. Chapter 2 and Chapter 2 discuss C Preprocessor, C library functions, and advanced data representation (data structure. The appendix provides the answers to the exercises and programming exercises and a wide range of C Programming references.

I wish you a successful academic career... the full text of the rest>

Diffuse: A. not full, ripple out B. Full, all times C. No constraint 3. manmanjinshan () manmanshan () manshan () manhua ()

A, B, C
 

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.