What do angled brackets mean when used in member name in C#?

南笙酒味 提交于 2020-01-05 15:15:32

问题


I was browsing through sources of PresentationCore.dll using DotPeek when I found this:

// Type: MS.Internal.TtfDelta.CMAP_HEADER
// Assembly: PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
// Assembly location: D:\Windows\Microsoft.NET\assembly\GAC_64\PresentationCore\v4.0_4.0.0.0__31bf3856ad364e35\PresentationCore.dll

using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

namespace MS.Internal.TtfDelta
{
  [NativeCppClass]
  [StructLayout(LayoutKind.Sequential, Size = 4)]
  internal struct CMAP_HEADER
  {
    private short <alignment member>;
  }
}

What does "private short <alignment member>" mean?


回答1:


Sometimes the disassembler doesn't know what a member of the code actually is, and it'll use a "guessed" type.

Disassemblers provide us with pseudo-code, even though it's very accurate in the case of dotPeek being used on the .NET Framework, it still isn't "real" code, like the base.ctor call in the following HashEntry class:

private class HashEntry
{
  public string[] names;
  public ulong[] values;

  public HashEntry(string[] names, ulong[] values)
  {
    base.\u002Ector();
    this.names = names;
    this.values = values;
  }
}

Which I took from mscorlib demonstrates this perfectly.



来源:https://stackoverflow.com/questions/12329907/what-do-angled-brackets-mean-when-used-in-member-name-in-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!