自从我用 C# 编程以来,我没有做过任何指示——而且我的 C++ 时代很久以前了。我想我应该更新我的知识,只是因为这里的另一个问题而和他们一起玩。我都理解它们,但我不知道如何将指针的地址写入控制台......
char c = 'c';
char d = 'd';
char e = 'e';
unsafe
{
char* cp = &d;
//How do I write the pointer address to the console?
*cp = 'f';
cp = &e;
//How do I write the pointer address to the console?
*cp = 'g';
cp = &c;
//How do I write the pointer address to the console?
*cp = 'h';
}
Console.WriteLine("c:{0}", c); //should display "c:h";
Console.WriteLine("d:{0}", d); //should display "d:f";
Console.WriteLine("e:{0}", e); //should display "e:g";
UsingConsole.WriteLine(*cp);
给了我指针地址的当前值......如果我想显示实际地址怎么办?