C # drip (ii)

Source: Internet
Author: User

1. Interface interface

Classes in C # cannot inherit more, meaning that a class cannot inherit from more than one base class at a time. But a class can inherit multiple interfaces, which is a constraint that specifies the functions that the class that inherits from it should implement.

An interface uses the interface keyword declaration, which is similar to a class declaration. The interface declaration is public by default.

An interface can inherit from another interface, at which point the interface has the methods of the interface it inherits from, and if a class inherits from that interface, then that class needs to implement all the methods.

2. Namespaces

Namespaces are designed to provide a way to separate a set of names from other names. The name of a class declared in one namespace does not conflict with the name of the same class declared in another namespace.

The definition of a namespace begins with the keyword namespace , followed by the name of the namespace, as follows:

namespace namespace_name{   //code declaration}

in order to invoke a function or variable that supports the namespace version, the name of the namespace is placed in front, as follows:

Namespace_name.item_name;

Namespaces support nesting, you can declare another namespace within one namespace:

namespace Namespace_name1 {   //Code declaration   namespace Namespace_name2    {     //code declaration   }}

3. Pre-processing instructions

Create symbolic constants #define preprocessor directives.

#define allows you to define a symbol so that the expression returns true by using the symbol as the expression passed to the #if instruction. It has the following syntax: #define Symbol

#define PI using System;namespace preprocessordappl{   class program   {      static void Main (string[] args)      {         #if (PI)            Console.WriteLine ("PI is defined");         #else            Console.WriteLine ("PI is not defined");         #endif         Console.readkey ();}}}   

C # drip (ii)

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.