相关疑难解决方法(0)

C#开启类型

可能重复:
C# - "开启类型"有比这更好的选择吗?

C#不支持切换对象的类型.模拟这个的最佳模式是什么:

switch (typeof(MyObj))
    case Type1:
    case Type2:
    case Type3:
Run Code Online (Sandbox Code Playgroud)

谢谢!

c#

163
推荐指数
3
解决办法
17万
查看次数

为什么不将"as something.GetType()"转换为有效?

此代码导致错误:type or namespace "index" could not be found.

foreach (var index in Model.UserAssets.Keys)
{
    foreach (var asset in Model.UserAssets[index])
    {
        var val = asset as index.getType();
    }
}
Run Code Online (Sandbox Code Playgroud)

为什么这不起作用?是因为index不在范围内(虽然它应该是)?

c# casting

0
推荐指数
1
解决办法
118
查看次数

标签 统计

c# ×2

casting ×1