CSHARP notes-1

Source: Internet
Author: User

1. The participates overload to call is determined statically (at compile time) rather than dynamically (at runtime ).

2. Dynamic type checking is possible because each object on the heap internally stores a little type token. This token can be retrieved by callingGetTypeMethodObject.

3.GetTypeIs evaluated dynamically at runtime;TypeofIs evaluated statically at compile time.

4. A struct can have all the members a class can, cannot the following:

  • A parameterless Constructor

  • A finalizer

  • Virtual members

A parameterless constructor that you can't override implicitly exists. This performs a bitwise-zeroing of its fields.

When you define a struct constructor, you must explicitly assign every field

5. Internal: accessible only within containing assembly or friend assemblies. The default accessibility for nonnested types

PRIVATE: the default accessibility members of a class or struct

Public: the implicit accessibility for members of an Enum or interface

6. A type caps the accessibility of its declared members

Class C {public void Foo (){}}

C'S (default)InternalAccessibility capsFoo'S accessibility, effectively makingFoo internal

7. Interface

1) A class can implement multiple interfaces

2) interface members are all implicitly Abstract

3) structs can implement interfaces

An interface can contain only methods, properties, events, and indexers, which noncoincidentally are precisely the members of a class that can be abstract.

Even thoughCountdownIs an internal class, its members that implementIenumeratorCan be called publicly by casting an instanceCountdownToIenumerator.

As a general rule:

  • Use classes and subclasses for types that naturally share an implementation.

  • Use interfaces for types that have independent implementations.

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.