English 中文(简体)
我如何能够在C#中展示一个要点。
原标题:How can I display a pointer address in C#?

我没有做任何事情,因为我早就在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";

使用<代码>Console.WriteLine(*cp);使我对点人地址的当前价值......如果我想要显示实际地址的话?

最佳回答
Console.WriteLine(new IntPtr(cp));
问题回答

根据管理法,垃圾收集器可以自由地把事情转移到你身上。 如果你在涉及事项的情况下提出反对,请予以注明。

char* cptr;
char achr =  a ;
cptr = &achr;
string strcptr = Convert.ToString((long)cptr, 16);
Console.WriteLine("Ox{0} is the char ptr hex address", strcptr);
char c =  c ;

unsafe
{
  Console.WriteLine("0x{0:x}", (ulong)&c);
  Console.WriteLine($"0x{(ulong)&c:x}");
}

这将显示...... 0x123abc(两次)

2. 将贵点改为特类。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签