如果您在C#code使用指针?有什么好处?难道是建议由男方(微软)?
Should you use pointers in your C# code? What are the benefits? Is it recommend by The Man (Microsoft)?
推荐答案从人自己:
的指针的使用很少需要在C#,但也有一些情况,需要它们。作为例子,使用不安全的上下文,以允许指针是由下列情况下保证:
The use of pointers is rarely required in C#, but there are some situations that require them. As examples, using an unsafe context to allow pointers is warranted by the following cases:
- 在现有的结构上盘交易
- 涉及的指针结构在其中高级COM或平台调用场景
- 在性能关键code
在其他情况下,使用不安全的情况下不鼓励。
The use of unsafe context in other situations is discouraged.
具体而言,不安全的情况下不应该被用来尝试写C code在C#。
注意:
code。使用不安全的上下文无法验证是安全的编写,因此它仅被执行时,code是完全可信的。换句话说,不安全code不能在不受信任的环境中执行。例如,你不能直接从互联网上运行不安全的code。
Code written using an unsafe context cannot be verified to be safe, so it will be executed only when the code is fully trusted. In other words, unsafe code cannot be executed in an untrusted environment. For example, you cannot run unsafe code directly from the Internet.
参考
更多推荐
如果您使用指针(不安全code)在C#中?
发布评论