如题,现在我有几行代码是这样的,string file = Request["XXX"] == null ? "" : Request["XXX"];
string[] filePath = (file.IndexOf(',') > -1) ? file.Split(',') : {file};这样就会报错,
但是我改成下面这样就不会出错string file = Request["XXX"] == null ? "" : Request["XXX"];
string[] test = { file };
string[] filePath = (file.IndexOf(',') > -1) ? file.Split(',') : test;请问这是什么原因,,求解答,,谢谢。
string[] filePath = (file.IndexOf(',') > -1) ? file.Split(',') : {file};这样就会报错,
但是我改成下面这样就不会出错string file = Request["XXX"] == null ? "" : Request["XXX"];
string[] test = { file };
string[] filePath = (file.IndexOf(',') > -1) ? file.Split(',') : test;请问这是什么原因,,求解答,,谢谢。
new String[]{file};
这属于初始化,可以这样,报错的那个属于=号赋值,不可以类型不一致
高手,你说string怎么赋值给string[]?
string[] filePath = (file.IndexOf(',') > -1) ? file.Split(',') : test;
string[] = bool ? string[]: string ;
string[] test = { file };
这个一点错误都没有。
这位哥,感谢你的回答,不过你可能没有看清楚我的问题,string[] test = { file };这个确实是没错误的,报错的那里也并不是把string赋值给string[],用孟子E章的果然可以,感谢2楼说出原因,谢谢,马上结贴。。