Sie sind auf Seite 1von 2

C# 2.0 Classes, Structs and Interfaces Distributed under Creative Commons Attribution-Share Alike 2.5 Generic http://creativecommons.org/licenses/by-sa/2.

2.5/ - (C) 2007 - FABIAN SOSA ESCALADA provides access to a characteristic of an object or a class / setter and getter /

represents a variable a value that associated can be with an computed at object or unique compile-time class signature

unique signature

inheritance
constitutent types (types used in member declarations) what members inherits from his base class inherited members are accesible derived (other classes can inherit this one ) base class ( this class inherits from ohter ) nested class implicity made... declaration modifiers members implicicity made... type of inheritance

members

executable code

define operators

Interfaces (can implement )

instantiated

properties

constants

definition

methods

class

reference type

can't be System.{Array, Delegate, Enum, ValueType}, and have only one

yes

All except it depends instance on transit several, and constr., yes accesibility ive re-implement finalizers, and modifier static constr.

constant field PTIN is the only inside PB, PT, property event allowed function INPT, IN, indexer, return combination of members PV (D) * type of mem. access (*) method* mod.

NW, PB, NW, PB, PT, NW, PB, PT, IN, PV, NW, PB, PT, IN, PV, ST, PT, IN, PV, ST, VR, SD, IN, PV VR, SD, OV, ST, RO, VL OV, AT, EX AT * can have variables and values but they must be null (*) nothing

abstract class

can't be instantiate d

yes

can be derived to abstract and non abstract

several, reimplement, and map intf. NO methods onto abstract

yes

abstract members are permitted (but not required)

yes

yes

static class sealed class can't be derived

NO

NO yes

NO can't be

NO

NO yes

yes

only ST and NOT PTIN

struct

value type

not support definition , but not inherits from supported System.ValueT ype Base interfaces!

several, and NW, PB, N.A. re-implement PT, IN, PV NW (only in nested) PB, PT, INT, PV * cannot be declared AT, PB, PT, IN, PV, VR, OV, ST

yes

yes

yes

yes

yes

yes

interface

define a contract

can inherit multiple base- N.A. interfaces

NO

yes, but without implementin g them

yes

yes

Diagram version: 2.0.0.1 Monday, October 8, 2007 PB = PUBLIC / PT = PROTECTED / PV = PRIVATE / IN = INTERNAL / ST = STATIC / VR = VIRTUAL / EX = EXTERNAL / AT = ABSTRACT / SD = SEALED / NW = NEW / RO = READ ONLY / VL = VOLATILE / OV =OVERRIDE / N.A. = NOT APPLICABLE

indexers

general

events

fields

unique signature

same class name / unique signature

same class name / unique signature

only one storage location across multiple instances

Every instance has a separate set of all instance fields

This diagram contains the most relevant points about the C# 2.0 language elements of the left column. Some obvious things are not present in the diagram to reduce the amount of text. I designed this diagram just to help myself in the migration from C++ and Delphi to C# so... be cool and provide some feedback!

embers
partial modifier allowed can declare virtual members ( polymorphic behavior ) constants and nested types instance constructors static constructors instance member

modifier particularities
new modifier / hides inherited member protected modifier protected internal abstract modifier

can supply typeparameter-list

internal modifier

types ( nested )

private modifier

sealed modifier

public modifier

static member

static modifier

constructor

NOTES (things to keep in mind)

operators

finalizers

PB, PTIN , PT, IN, PV (D)

yes

can have ( but hidden members will not be removed )

1. can't use "this" to access container's members

2. constant or type declaration implicitly declares a static member

yes

yes

yes

yes

Yes, methods, properties, indexers, and events implicity static

NO

1. When a non-abstract class is derived from an abstract class, the non-abstract class shall include actual implementations of all inherited abstract members, thereby overriding those abstract members NO NO must have impossible no 1. implicity inherits from type object The sealed modifier is used to prevent derivation from a class N.A. Since inheritance isnt supported

2. Explicit interface member implementations cannot be abstract, but explicit interface member implementations are of course permitted to call abstract methods 2. shall only have static members, and shall not have protected internal

doesn't have

yes, can cannot define, declare but implicitly has yes having a parameterless paramete one rs

NO!

yes

PB, IN, PV (D)

not permitted, always implicit

1. the simple types provided by C#, such as int, double, and bool, are, in fact, all 2. values can't be null are structs types

1. member acces casted to solve ambiguity

Only most important features are shown

Das könnte Ihnen auch gefallen