gpt4 book ai didi

c# - 静态方法中的 GetType

转载 作者:IT王子 更新时间:2023-10-29 04:03:21 27 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
.NET: Determine the type of “this” class in its static method

如何使 GetType() 可从 static 方法访问?

我有这个抽象基类

abstract class MyBase
{
public static void MyMethod()
{
var myActualType = GetType(); // this is an instance method
doSomethingWith(myActualType);
}
}

以及该类的实现。 (我可以有很多实现。)

class MyImplementation : MyBase 
{
// stuff
}

如何让 myActualType 成为 typeof(MyImplementation)

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com