我想在Cint *是如何在C#中布尔?
public static void Main(string[] args)
{
unsafe
{
int i = 5;
int* j = &i;
Console.WriteLine(j); //cannot convert from 'int*' to 'bool'
}
}
使用在C#中的指针就像我有一个关于这两个代码查询:
- 如何使用/编译不安全?
- 为什么
Console.Writeline(j)
正试图转换j to bool
?
最好是将指针转换为`IntPtr`(或`int`,`uint`等)。 – leppie 2011-01-23 17:20:27