我Unable to cast object of type 'System.Int64' to type 'System.String'.
从下面的代码片段中得到了这个
:
IList<long> Ids = new List<long>();
Ids.Add(6962056);
Ids.Add(7117210);
Ids.Add(13489241);
var stringIds = Ids.Cast<string>().ToArray();
Run Code Online (Sandbox Code Playgroud)
和Booooooooooooom ....想法?
你不能把长字符串转换为字符串.您需要指定要将long转换为字符串的操作.我更喜欢使用Linq来选择新值:
var stringIds = Ids.Select(id => id.ToString());
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
339 次 |
| 最近记录: |