bool b;
unsafe
{
bool* p1 = &b;
Console.WriteLine("p1: {0}", p1->ToString());
}
给我
P1:假
但我想打印地址。我该怎么办?
答案 0 :(得分:3)
using System;
namespace Test81
{
class MainClass
{
public static void Main(string[] args)
{
bool b;
unsafe
{
bool* p1 = &b;
Console.WriteLine("p1: 0x{0:X}", new IntPtr(p1).ToInt64());
}
}
}
}