简体   繁体   English

.NET中C#指针的使用

[英]Uses of C# pointers in .Net

我想知道是否有人可以给我一个在.Net中的C#中使用指针的好例子,为什么您选择使用指针?

This isn't really a question to specific to ASP.NET. 对于ASP.NET来说,这并不是真正的问题。

If you are going to use pointers in .NET, the predominant reason is that you have an interop scenario where it is going to be easier to use pointers in unsafe code instead of IntPtr instances. 如果要在.NET中使用指针,则主要原因是您遇到了一个互操作方案,在该方案中,在不安全的代码中而不是IntPtr实例中使用指针将变得更加容易。

The second most popular (and distant) reason is because you might actually have a performance gain in processing large amounts of data in unsafe code than in managed code. 第二个最受欢迎(也是很遥远)的原因是,与不托管代码相比,使用不安全代码处理大量数据实际上可能会提高性能。 Image processing algorithms are a good example of this. 图像处理算法就是一个很好的例子。

If you wanted to do some performant image processing for a web application, you might want to consider using pointers there. 如果要为Web应用程序执行一些高性能的图像处理,则可能需要考虑在其中使用指针。 See Image Processing Basics in C# on codeproject.com. 请参阅codeproject.com上C#中的“图像处理基础知识”

仅当使用非托管代码或进行点名调用时,才需要使用指针。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM