C ++/CLI vs CSHARP

Source: Internet
Author: User
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;
}
}

 

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.