Common C # Keywords in a detailed tutorial

Source: Internet
Author: User
Tags modifiers


Many of the students in the background of the study site are some of the key words of C # can not touch the brain, and now with you to learn the meaning of these keywords

Type

Void
When used as the return type of a method, the Void keyword specifies that the method does not return a value.

Void is not allowed in the parameter list of a method. Declare a parameterless method that does not return a value, using the following form:

Ovid SampleMethod ();

Var

Variables declared in the method scope can have implicitly type var. An implicitly typed local variable is a strongly typed variable (as if you have declared the type), but the type is determined by the compiler. has a return value


Reference type

Class

Class is declared using the keyword class.


Commissioned

The declaration of a delegate type is similar to a method signature, with a return value and any number of arguments of any type:
public delegate void Testdelegate (String message);

public delegate int Testdelegate (MyType m, long num);

Delegate is a reference type that can be used to encapsulate named or anonymous methods. A delegate is similar to a function pointer in C + +, but a delegate is type-safe and reliable.

Interface

The interface contains only the signature of a method, property, event, or indexer. The implementation of a member is done in the class or struct that implements the interface.

Object

The object type is an alias for object in the. NET Framework. In the unified type System of C #, all types (predefined types, user-defined types, reference types, and value types) are inherited directly or indirectly from Object. You can assign a value of any type to a variable of type object. The process of converting a variable of a value type to an object is called boxing. The process of converting a variable of an object type to a value type is called unboxing.

String

The string type represents a sequence of 0 or more Unicode characters. String is the alias of a string in the. NET Framework.

Although string is a reference type, the equality operator (= = and! =) is defined to compare the value of a string object rather than a reference. This makes testing of string equality more intuitive.
Www.51rgb.com

Modifier

Override

To extend or modify an abstract implementation or virtual implementation of an inherited method, property, indexer, or event, you must use the override modifier.

Virtual

The virtual keyword is used to decorate methods, properties, indexers, or event declarations, and to make them overridden in derived classes. For example, this method can be overridden by any class that inherits it.

Volatile

The volatile keyword indicates that a field can be modified by multiple concurrently executing threads. Fields declared as volatile are not limited by compiler optimizations (presumably accessed by a single thread). This ensures that the field is present at any time with the most recent value.

Unsafe

The unsafe keyword represents an unsafe context, which is required for any operation involving pointers.

Static

Use the static modifier to declare a static member that belongs to the type itself rather than to a particular object. The static modifier can be used for classes, fields, methods, properties, operators, events, and constructors, but not for types other than indexers, destructors, or classes.

Sealed

When the sealed modifier is applied to a class, this modifier prevents other classes from inheriting from the class. In the following example, Class B inherits from class A, but no class can inherit from Class B.

ReadOnly

The ReadOnly keyword is a modifier that can be used on a field. When a field declaration includes a readonly modifier, the field assignment introduced by the Declaration can only occur as part of the declaration or in a constructor of the same class.

extern

The extern modifier is used to declare methods that are implemented externally. The common use of the extern modifier is to use the DllImport property with the Interop service when it is being transferred into unmanaged code. In this case, the method must also be declared as static

Event

The event keyword is used to declare events in the Publisher class.

Const

The const keyword is used to modify the declaration of a field or local variable. It specifies that the value of a field or local variable is constant and cannot be modified.

Abstract

The abstract modifier can be used with classes, methods, properties, indexers, and events. Use the abstract modifier in a class declaration to indicate that a class can be a base class only for other classes. A member that is marked as abstract or contained in an abstract class must be implemented by a class derived from an abstract class.

Access modifiers

Internal

The internal keyword is an access modifier for a type and a member of a type. An internal type or member is accessible only in files of the same assembly

Private

The Private keyword is a member access modifier. Private access is the lowest level of access allowed. Private members are accessible only in the class and struct in which they are declared

Protected

The protected keyword is a member access modifier. A protected member can be accessed by a derived class instance in the class in which it resides.

Public

The Public keyword is an access modifier for a type and type member. Public access is the highest level of access allowed.


Abstract can be used with classes, methods, properties, indexers, and events.
Identifies a class or method that must be implemented that can be extended but not manifested.

As a conversion operator, NULL is returned if the conversion fails.

Base is used to access a group member that is hidden by a member of the same name in a derived class or construct.

Catch defines a block of code that executes in-block code when a particular type of exception is thrown.
See try and finally.

Checked is both an operator and a statement.
Ensures that when the compiler runs, the overflow that occurs when an integer type operation or conversion is checked.

The const identifies a variable value that can be computed at compile time, that is, a value that cannot be modified once it is assigned.

delegate specifies that a declaration is a delegate type. The delegate encapsulates the method as a callable entity,
Can be called in the delegate entity.

An enum represents a value type for a named constant cluster.

Event allows a class or object to provide a member of the notification, and he must be a delegate type.

Explicit a operator that defines a user-defined conversion operator,
Typically used to convert an built-in type to a user-defined type or to a reverse operation.
The display conversion operator must be called when the conversion is re-converted.

extern identifies a method that will be implemented externally (usually not in the C # language).


Finally defines a block of code that executes when program control leaves the try code fast. See try and catch.


Fixed assigns a pointer to a variable at a fixed memory location when a block of code executes.


foreach is used to traverse the elements of a cluster.


Goto a jump statement that redirects program execution to a label statement.

Implicit an operator that defines a user-defined conversion operator.
Typically used to convert a predefined type to a user-defined type or to a reverse operation.
The implicit conversion operator must be used at the time of conversion.

interface specifies a declaration as an interface type, which is the contract that the implementation class or construct must follow.

Internal an access modifier.

namespace defines the type and namespace of a logical group.

Operator is used to declare or load an operator.

Out identifies the parameters that are affected by a parameter value, but when the method is passed in,
This parameter does not have to be initialized first.

The params declares an array of arguments. If used, the last parameter specified must be modified.
Optional parameters are allowed.

ReadOnly identifies the value of a variable that cannot be modified after initialization.

Ref identifies a parameter that may be affected by a parameter value.

Sealed prevents types from being derived, preventing methods and property from being overwritten.

sizeof an operator that returns the length of a value type in bytes.

Stackalloc returns a pointer to a block of memory allocated on the heap.

A struct struct is a value type that can declare constants, fields, methods, property,
Indexers, operators, constructors, and inline types.

Throw throws an exception.

One of the parts of the try exception handling code block. The try code block includes possible
The code that throws the exception. See Catch and finally keywords.

typeof an operator that returns the type of the passed-in parameter.

Unchecked no overflow check.

Unsafe labels a code block, method, or class that contains pointer operations.

Using when used with namespaces, the Using keyword allows access to the types in that namespace,
Without specifying its full name. Also used to define the scope of the finalization operation.
Virtual a method modifier that identifies a method that can be overwritten.

Volatile identifies a attribute that can be modified by the operating system, certain hardware devices, or concurrent threads.



A generic constructor is always of the public type, and if it is private, it indicates that the class cannot be instantiated, which is typically used for classes that contain only static members.

The overloading of virtual methods is declared in a derived class, requiring that the override keyword be added to the declaration, and that there must be no new,static or virtual modifiers.

The sealed class uses the sealed modifier in the declaration, which prevents the class from being inherited by other classes.
C # Keywords


Many of the students in the background of the study site are some of the key words of C # can not touch the mind, now 51RGB small q group 162542073 and everyone to learn about the meaning of these keywords

Type

Void

When used as the return type of a method, the Void keyword specifies that the method does not return a value.

Void is not allowed in the parameter list of a method. Declare a parameterless method that does not return a value, using the following form:

Ovid SampleMethod ();

Var

Variables declared in the method scope can have implicitly type var. An implicitly typed local variable is a strongly typed variable (as if you have declared the type), but the type is determined by the compiler. has a return value


Reference type

Class

Class is declared using the keyword class.


Commissioned

The declaration of a delegate type is similar to a method signature, with a return value and any number of arguments of any type:
public delegate void Testdelegate (String message);

public delegate int Testdelegate (MyType m, long num);

Delegate is a reference type that can be used to encapsulate named or anonymous methods. A delegate is similar to a function pointer in C + +, but a delegate is type-safe and reliable.

Interface

The interface contains only the signature of a method, property, event, or indexer. The implementation of a member is done in the class or struct that implements the interface.

Object

The object type is an alias for object in the. NET Framework. In the unified type System of C #, all types (predefined types, user-defined types, reference types, and value types) are inherited directly or indirectly from Object. You can assign a value of any type to a variable of type object. The process of converting a variable of a value type to an object is called boxing. The process of converting a variable of an object type to a value type is called unboxing.

String

The string type represents a sequence of 0 or more Unicode characters. String is the alias of a string in the. NET Framework.

Although string is a reference type, the equality operator (= = and! =) is defined to compare the value of a string object rather than a reference. This makes testing of string equality more intuitive.


Modifier

Override

To extend or modify an abstract implementation or virtual implementation of an inherited method, property, indexer, or event, you must use the override modifier.

Virtual

The virtual keyword is used to decorate methods, properties, indexers, or event declarations, and to make them overridden in derived classes. For example, this method can be overridden by any class that inherits it.

Volatile

The volatile keyword indicates that a field can be modified by multiple concurrently executing threads. Fields declared as volatile are not limited by compiler optimizations (presumably accessed by a single thread). This ensures that the field is present at any time with the most recent value.

Unsafe

The unsafe keyword represents an unsafe context, which is required for any operation involving pointers.

Static

Use the static modifier to declare a static member that belongs to the type itself rather than to a particular object. The static modifier can be used for classes, fields, methods, properties, operators, events, and constructors, but not for types other than indexers, destructors, or classes.

Sealed

When the sealed modifier is applied to a class, this modifier prevents other classes from inheriting from the class. In the following example, Class B inherits from class A, but no class can inherit from Class B.

ReadOnly

The ReadOnly keyword is a modifier that can be used on a field. When a field declaration includes a readonly modifier, the field assignment introduced by the Declaration can only occur as part of the declaration or in a constructor of the same class.

extern

The extern modifier is used to declare methods that are implemented externally. The common use of the extern modifier is to use the DllImport property with the Interop service when it is being transferred into unmanaged code. In this case, the method must also be declared as static

Event

The event keyword is used to declare events in the Publisher class.

Const

The const keyword is used to modify the declaration of a field or local variable. It specifies that the value of a field or local variable is constant and cannot be modified.

Abstract

The abstract modifier can be used with classes, methods, properties, indexers, and events. Use the abstract modifier in a class declaration to indicate that a class can be a base class only for other classes. A member that is marked as abstract or contained in an abstract class must be implemented by a class derived from an abstract class.
Www.51rgb.com
Access modifiers

Internal

The internal keyword is an access modifier for a type and a member of a type. An internal type or member is accessible only in files of the same assembly

Private

The Private keyword is a member access modifier. Private access is the lowest level of access allowed. Private members are accessible only in the class and struct in which they are declared

Protected

The protected keyword is a member access modifier. A protected member can be accessed by a derived class instance in the class in which it resides.

Public

The Public keyword is an access modifier for a type and type member. Public access is the highest level of access allowed.


Abstract can be used with classes, methods, properties, indexers, and events.
Identifies a class or method that must be implemented that can be extended but not manifested.

As a conversion operator, NULL is returned if the conversion fails.

Base is used to access a group member that is hidden by a member of the same name in a derived class or construct.

Catch defines a block of code that executes in-block code when a particular type of exception is thrown.
See try and finally.

Checked is both an operator and a statement.
Ensures that when the compiler runs, the overflow that occurs when an integer type operation or conversion is checked.

The const identifies a variable value that can be computed at compile time, that is, a value that cannot be modified once it is assigned.

delegate specifies that a declaration is a delegate type. The delegate encapsulates the method as a callable entity,
Can be called in the delegate entity.

An enum represents a value type for a named constant cluster.

Event allows a class or object to provide a member of the notification, and he must be a delegate type.

Explicit a operator that defines a user-defined conversion operator,
Typically used to convert an built-in type to a user-defined type or to a reverse operation.
The display conversion operator must be called when the conversion is re-converted.

extern identifies a method that will be implemented externally (usually not in the C # language).


Finally defines a block of code that executes when program control leaves the try code fast. See try and catch.


Fixed assigns a pointer to a variable at a fixed memory location when a block of code executes.


foreach is used to traverse the elements of a cluster.


Goto a jump statement that redirects program execution to a label statement.

Implicit an operator that defines a user-defined conversion operator.
Typically used to convert a predefined type to a user-defined type or to a reverse operation.
The implicit conversion operator must be used at the time of conversion.

interface specifies a declaration as an interface type, which is the contract that the implementation class or construct must follow.

Internal an access modifier.

namespace defines the type and namespace of a logical group.

Operator is used to declare or load an operator.

Out identifies the parameters that are affected by a parameter value, but when the method is passed in,
This parameter does not have to be initialized first.

The params declares an array of arguments. If used, the last parameter specified must be modified.
Optional parameters are allowed.

ReadOnly identifies the value of a variable that cannot be modified after initialization.

Ref identifies a parameter that may be affected by a parameter value.

Sealed prevents types from being derived, preventing methods and property from being overwritten.

sizeof an operator that returns the length of a value type in bytes.

Stackalloc returns a pointer to a block of memory allocated on the heap.

A struct struct is a value type that can declare constants, fields, methods, property,
Indexers, operators, constructors, and inline types.

Throw throws an exception.

One of the parts of the try exception handling code block. The try code block includes possible
The code that throws the exception. See Catch and finally keywords.

typeof an operator that returns the type of the passed-in parameter.

Unchecked no overflow check.

Unsafe labels a code block, method, or class that contains pointer operations.

Using when used with namespaces, the Using keyword allows access to the types in that namespace,
Without specifying its full name. Also used to define the scope of the finalization operation.
Virtual a method modifier that identifies a method that can be overwritten.

Volatile identifies a attribute that can be modified by the operating system, certain hardware devices, or concurrent threads.



A generic constructor is always of the public type, and if it is private, it indicates that the class cannot be instantiated, which is typically used for classes that contain only static members.

The overloading of virtual methods is declared in a derived class, requiring that the override keyword be added to the declaration, and that there must be no new,static or virtual modifiers.

The sealed class uses the sealed modifier in the declaration, which prevents the class from being inherited by other classes.
C # Keywords


Many of the students in the background of the study site are some of the key words of C # can not touch the mind, now 51RGB small q group 162542073 and everyone to learn about the meaning of these keywords

Type

Void

When used as the return type of a method, the Void keyword specifies that the method does not return a value.

Void is not allowed in the parameter list of a method. Declare a parameterless method that does not return a value, using the following form:

Ovid SampleMethod ();

Var

Variables declared in the method scope can have implicitly type var. An implicitly typed local variable is a strongly typed variable (as if you have declared the type), but the type is determined by the compiler. has a return value


Reference type

Class

Class is declared using the keyword class.


Commissioned

The declaration of a delegate type is similar to a method signature, with a return value and any number of arguments of any type:
public delegate void Testdelegate (String message);

public delegate int Testdelegate (MyType m, long num);

Delegate is a reference type that can be used to encapsulate named or anonymous methods. A delegate is similar to a function pointer in C + +, but a delegate is type-safe and reliable.
Www.51rgb.com
Interface

The interface contains only the signature of a method, property, event, or indexer. The implementation of a member is done in the class or struct that implements the interface.

Object

The object type is an alias for object in the. NET Framework. In the unified type System of C #, all types (predefined types, user-defined types, reference types, and value types) are inherited directly or indirectly from Object. You can assign a value of any type to a variable of type object. The process of converting a variable of a value type to an object is called boxing. The process of converting a variable of an object type to a value type is called unboxing.

String

The string type represents a sequence of 0 or more Unicode characters. String is the alias of a string in the. NET Framework.

Although string is a reference type, the equality operator (= = and! =) is defined to compare the value of a string object rather than a reference. This makes testing of string equality more intuitive.


Modifier

Override

To extend or modify an abstract implementation or virtual implementation of an inherited method, property, indexer, or event, you must use the override modifier.

Virtual

The virtual keyword is used to decorate methods, properties, indexers, or event declarations, and to make them overridden in derived classes. For example, this method can be overridden by any class that inherits it.

Volatile

The volatile keyword indicates that a field can be modified by multiple concurrently executing threads. Fields declared as volatile are not limited by compiler optimizations (presumably accessed by a single thread). This ensures that the field is present at any time with the most recent value.

Unsafe

The unsafe keyword represents an unsafe context, which is required for any operation involving pointers.

Static

Use the static modifier to declare a static member that belongs to the type itself rather than to a particular object. The static modifier can be used for classes, fields, methods, properties, operators, events, and constructors, but not for types other than indexers, destructors, or classes.

Sealed

When the sealed modifier is applied to a class, this modifier prevents other classes from inheriting from the class. In the following example, Class B inherits from class A, but no class can inherit from Class B.

ReadOnly

The ReadOnly keyword is a modifier that can be used on a field. When a field declaration includes a readonly modifier, the field assignment introduced by the Declaration can only occur as part of the declaration or in a constructor of the same class.

extern

The extern modifier is used to declare methods that are implemented externally. The common use of the extern modifier is to use the DllImport property with the Interop service when it is being transferred into unmanaged code. In this case, the method must also be declared as static

Event

The event keyword is used to declare events in the Publisher class.

Const

The const keyword is used to modify the declaration of a field or local variable. It specifies that the value of a field or local variable is constant and cannot be modified.

Abstract

The abstract modifier can be used with classes, methods, properties, indexers, and events. Use the abstract modifier in a class declaration to indicate that a class can be a base class only for other classes. A member that is marked as abstract or contained in an abstract class must be implemented by a class derived from an abstract class.
Www.51rgb.com
Access modifiers

Internal

The internal keyword is an access modifier for a type and a member of a type. An internal type or member is accessible only in files of the same assembly

Private

The Private keyword is a member access modifier. Private access is the lowest level of access allowed. Private members are accessible only in the class and struct in which they are declared

Protected

The protected keyword is a member access modifier. A protected member can be accessed by a derived class instance in the class in which it resides.

Public

The Public keyword is an access modifier for a type and type member. Public access is the highest level of access allowed.


Abstract can be used with classes, methods, properties, indexers, and events.
Identifies a class or method that must be implemented that can be extended but not manifested.

As a conversion operator, NULL is returned if the conversion fails.

Base is used to access a group member that is hidden by a member of the same name in a derived class or construct.

Catch defines a block of code that executes in-block code when a particular type of exception is thrown.
See try and finally.

Checked is both an operator and a statement.
Ensures that when the compiler runs, the overflow that occurs when an integer type operation or conversion is checked.

The const identifies a variable value that can be computed at compile time, that is, a value that cannot be modified once it is assigned.

delegate specifies that a declaration is a delegate type. The delegate encapsulates the method as a callable entity,
Can be called in the delegate entity.

An enum represents a value type for a named constant cluster.

Event allows a class or object to provide a member of the notification, and he must be a delegate type.

Explicit a operator that defines a user-defined conversion operator,
Typically used to convert an built-in type to a user-defined type or to a reverse operation.
The display conversion operator must be called when the conversion is re-converted.

extern identifies a method that will be implemented externally (usually not in the C # language).


Finally defines a block of code that executes when program control leaves the try code fast. See try and catch.


Fixed assigns a pointer to a variable at a fixed memory location when a block of code executes.


foreach is used to traverse the elements of a cluster.


Goto a jump statement that redirects program execution to a label statement.

Implicit an operator that defines a user-defined conversion operator.
Typically used to convert a predefined type to a user-defined type or to a reverse operation.
The implicit conversion operator must be used at the time of conversion.

interface specifies a declaration as an interface type, which is the contract that the implementation class or construct must follow.

Internal an access modifier.

namespace defines the type and namespace of a logical group.

Operator is used to declare or load an operator.

Out identifies the parameters that are affected by a parameter value, but when the method is passed in,
This parameter does not have to be initialized first.

The params declares an array of arguments. If used, the last parameter specified must be modified.
Optional parameters are allowed.

ReadOnly identifies the value of a variable that cannot be modified after initialization.

Ref identifies a parameter that may be affected by a parameter value.

Sealed prevents types from being derived, preventing methods and property from being overwritten.

sizeof an operator that returns the length of a value type in bytes.

Stackalloc returns a pointer to a block of memory allocated on the heap.

A struct struct is a value type that can declare constants, fields, methods, property,
Indexers, operators, constructors, and inline types.

Throw throws an exception.

One of the parts of the try exception handling code block. The try code block includes possible
The code that throws the exception. See Catch and finally keywords.

typeof an operator that returns the type of the passed-in parameter.

Unchecked no overflow check.

Unsafe labels a code block, method, or class that contains pointer operations.

Using when used with namespaces, the Using keyword allows access to the types in that namespace,
Without specifying its full name. Also used to define the scope of the finalization operation.
Virtual a method modifier that identifies a method that can be overwritten.

Volatile identifies a attribute that can be modified by the operating system, certain hardware devices, or concurrent threads.



A generic constructor is always of the public type, and if it is private, it indicates that the class cannot be instantiated, which is typically used for classes that contain only static members.

The overloading of virtual methods is declared in a derived class, requiring that the override keyword be added to the declaration, and that there must be no new,static or virtual modifiers.

The sealed class uses the sealed modifier in the declaration, which prevents the class from being inherited by other classes.
For more video tutorials, go to 51RGB website http://www.51rgb.com

Common C # Keywords in a detailed tutorial

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.