小编tan*_*eye的帖子

为什么(string)int32总是抛出:无法将类型'int'转换为'string'

为什么(string)int32总是抛出:无法将类型'int'转换为'string'

public class Foo
    {   
        private int FooID;
        public Foo()
        {
            FooID = 4;
            string s = (string)FooID; //throws compile error
            string sss = FooID.ToString(); //no compile error
        }
    }
Run Code Online (Sandbox Code Playgroud)

c# compilation

4
推荐指数
5
解决办法
2万
查看次数

标签 统计

c# ×1

compilation ×1