Код: Выделить всё
public struct IDValue64 : IStructMessage
{
public static StructMessageParser Parser = new StructMessageParser();
public const int SizeOf = 16;
public long Id;
public long Value;
public override string ToString()
{
MessageFormat format = new MessageFormat();
format.WriteLine("{");
format.Indent();
format.WriteLine("Id : " + Id.ToString() + ",");
format.WriteLine("Value : " + Value.ToString() + " }");
format.Outdent();
return format.ToString();
}
}
unsafe public struct RepeatedIDValue64_8
{
const int BuffSize = 128;
public const int MaxCount = 8;
public int Count;
public fixed byte Buffer[BuffSize];
public int GetCount()
{
return Count;
}
public int GetMaxCount()
{
return MaxCount;
}
public ref IDValue64 Get(int index)
{
if (index < 0 || index >= Count)
{
string message = string.Format("class RepeatedIDValue64_8 index{0} count{1}", index, Count);
throw new ArgumentOutOfRangeException(message);
}
fixed (byte* pb = Buffer)
{
IDValue64* pbs = (IDValue64*)pb;
return ref pbs[index]; // is safe?
}
}
public override string ToString()
{
StringBuilder sb = new StringBuilder();
sb.Append("{\n");
for (int i = 0; i < Count; i++)
{
sb.Append("[" + i.ToString() + "]:");
sb.Append(Get(i).ToString()); // core pos
}
sb.Append('}');
return sb.ToString();
}
}
это дамп ядра clrstack
clrstack
Подробнее здесь: https://stackoverflow.com/questions/785 ... in-c-sharp