我的代码中有以下行:
static if (typeof(val) == string) {
Run Code Online (Sandbox Code Playgroud)
它没有编译并返回错误Error: incompatible types for ((string) == (string)): cannot use '==' with types.检查变量类型的正确方法是什么?
正确的方法是使用它周围的is表达式:is(A == b)像这样:
static if (is(typeof(val) == string)) {
Run Code Online (Sandbox Code Playgroud)