【发布时间】:2015-07-17 13:28:17
【问题描述】:
这是我的代码:
List<string> deviceScreenshot=new List<string>();
List<string> fiddlerScreenshot=new List<string>();
if(string.IsNullOrEmpty(summary[3].ToString())==false)
deviceScreenshot=summary[3];
else
deviceScreenshot="Screenshot not found";
if(string.IsNullOrEmpty(summary[4].ToString())==false)
fiddlerScreenshot=summary[4];
else
fiddlerScreenshot="Screenshot not found";
我收到以下错误消息!
无法将类型“字符串”隐式转换为 'System.Collections.Generic.List' (CS0029) - D:\automation\OmnitureStatistics\OmnitureStatistics\TeardownUserCode.cs:144,23
请告诉我解决方案!
【问题讨论】:
-
什么是
deviceScreenshot -
是列表
- List deviceScreenshot=new List (); List fiddlerScreenshot=new List (); -
如果
deviceScreenshot是集合,那么您可以像这样添加 'deviceScreenshot.add(summary[3]);` -
与此处的问题无关,但您可以使 if 条件看起来像
if(!string.IsNullOrEmpty(summary[3].ToString()))而不是if(string.IsNullOrEmpty(summary[3].ToString())==false)以使其看起来更好看。 -
嗨@Rahul,它真的有效.. 谢谢:)... 'deviceScreenshot.add(summary[3]);' 之间有什么区别和 'deviceScreenshot=summary[3];'
标签: c# .net list collections ranorex