还有什么比Marshal.SizeOf更准确的方法吗?

时间:2019-08-03 12:59:35

标签: c# char sizeof

char的大小在c#中为2个字节,但Marshal.SizeOf(typeof(char))等于1:

using System;
using System.Runtime.InteropServices;

class Program
{
    static void Main()
    {
        Console.WriteLine(Marshal.SizeOf(typeof(char)));
        Console.ReadKey();
    }
}

输出:1

是否有任何方法比.Net中的Marshal.SizeOf更准确?

0 个答案:

没有答案
相关问题