ValueType上的“ InstanceMethod”和“ StaticMethodref Type self”之间的区别?

问题描述

struct Vip
{
    internal int Id;
    internal int Age;
    internal int Weight;
    internal int Position;

    public void Move(int step)
    {
        Position += step;
    }

    public static void Move(ref Vip self,int step)
    {
        self.Position += step;
    }
    
    public static unsafe void MoveFast(ViP* self,int step)
    {
        self->Position += step;
    }
}

静态方法中的第一个参数扮演“ this”的角色。 我测试了这三种方法,发现实例方法比该方法显式包含“ this”的速度快。

在CLR下发生了什么事?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)