C#/Xamarin 等效于 class.getSimpleName()

Al *_*ath 1 c# xamarin.android

我正在手动将 Android Studio 项目移植到 Visual Studio/Xamarin。我有这个Java代码:

throw new IllegalStateException(MyClass.class.getSimpleName() + " is not initialized.");
Run Code Online (Sandbox Code Playgroud)

我正在尝试为.getSimpleName().

我在网上找到了一些可以尝试的东西:

throw new IllegalStateException(MyClass.ShortClassName +" is not initialized.);
throw new IllegalStateException(nameOf(MyClass) +  " is not initialized.");
Run Code Online (Sandbox Code Playgroud)

但这些都不编译。
你能告诉我什么是等价物吗?

Fel*_*ano 5

你可以试试typeof(myclass).Name。为了完整起见,如果您需要带有命名空间的扩展名称,请使用:typeof(myclass).FullName