Class vs. struct

Structs differ from classes in several important ways:

  • Structs are value types.
  • All struct types implicitly inherit from the class System.ValueType.
  • Assignment to a variable of a struct type creates a copy of the value being assigned.
  • The default value of a struct is the value produced by setting all value type fields to their default value and all reference type fields to null.
  • Boxing and unboxing operations are used to convert between a struct type and object.
  • The meaning of this is different for structs.
  • Instance field declarations for a struct are not permitted to include variable initializers.
  • A struct is not permitted to declare a parameterless instance constructor.
  • A struct is not permitted to declare a destructor.

Sursa: http://msdn.microsoft.com/en-us/library/aa664471(VS.71).aspx

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s