Kenny KerrA comparison table in the Article C ++: the most powerful language for. NET Framework programming:
Description |
C ++/CLI |
C # |
Create an object of reference type |
Referencetype ^ h = gcnew referencetype; |
Referencetype H = new referencetype (); |
Create a value type object |
Valuetype V (3, 4 ); |
Valuetype v = new valuetype (3, 4 ); |
Reference Type on Stack |
Referencetype h; |
N/ |
CallDisposeMethod |
Referencetype ^ h = gcnew referencetype; Delete h; |
Referencetype H = new referencetype (); (Idisposable) H). Dispose (); |
ImplementationDisposeMethod |
~ Typename (){} |
Void idisposable. Dispose (){} |
ImplementationFinalizeMethod |
! Typename (){} |
~ Typename (){} |
Boxing) |
Int ^ h = 123; |
Object H = 123; |
Unboxing) |
Int ^ HI = 123; Int c = * Hi; |
Object H = 123; Int I = (INT) h; |
Define reference type |
Ref class referencetype {}; Ref struct referencetype {}; |
Class referencetype {} |
Define Value Type |
Value class valuetype {}; Value struct valuetype {}; |
Struct valuetype {} |
Usage attributes |
H. Prop = 123; Int V = H. Prop; |
H. Prop = 123; Int V = H. Prop; |
Define attributes |
Property string ^ name { String ^ get () { Return m_value; } Void set (string ^ value) { M_value = value; } } |
String name { Get { Return m_name; } Set { M_name = value; } } |