开发者

how i should create a reference of a object of a class [closed]

开发者 https://www.devze.com 2023-01-04 02:27 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical a开发者_运维知识库ndcannot be reasonably answered in its current for
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical a开发者_运维知识库nd cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 12 years ago.

How i get address pointer of a object


If you are willing to use unsafe code you can use pointers. Here is an example from MSDN:

// assume class Point { public int x, y; }
// pt is a managed variable, subject to garbage collection.
Point pt = new Point();
// Using fixed allows the address of pt members to be
// taken, and "pins" pt so it isn't relocated.
fixed ( int* p = &pt.x )
{
    *p = 1; 
}

However you should probably avoid doing this unless you understand what you are doing and know why you need this feature.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号