我想要一个方法来返回一个列表,其中包含两个具有两种不同数据类型的列表,例如:
List<List<object>> parentList = new List<List<object>>();
List<string> childList1 = new List<string>();
List<DataRow> childList2 = new List<DataRow>();
parentList.Add(childList1);
parentList.Add(childList2);
return parentList;
Run Code Online (Sandbox Code Playgroud)
按照上面的代码,我收到一个错误
'System.Collections.Generic.List> .Add(System.Collections.Generic.List)'的最佳重载方法匹配有一些无效的参数
请任何人都可以建议我处理这个问题的最佳方法.
谢谢
我从数据库中获取一些应该有双引号的字符串值,例如:
"DoubleQuotes"
Run Code Online (Sandbox Code Playgroud)
但是当它来到c#部分上面的字符串值变成:
\"DoubleQuotes\"
Run Code Online (Sandbox Code Playgroud)
我甚至尝试过使用替换方法,但它取出了\但也"从各处移除.
码:
repository = new Repository();
string genericTemplate = Convert.ToString(@repository.GetTemplateWithoutFormulas(sheetName)); // this returns the string value from the db
return genericTemplate;
Run Code Online (Sandbox Code Playgroud)
我得到的浏览器上的O/p是:
"{\"version\":\"9.40.20153.0\",\"sheetCount\":2,\"sheets\":{\"Sheet1\":{\"name\":\"Sheet1\",\"selections\":{\"0\":{\"row\":1,\"rowCount\":1,\"col\":1,\"colCount\":1}},\"rowCount\":200,\"columnCount\":20,\"activeRow\":1,\"activeCol\":1,\"theme\":\"Office\",\"rowHeaderData\":{\"defaultDataNode\":{\"style\":{\"themeFont\":\"Body\"}}},\"colHeaderData\":{\"defaultDataNode\":{\"style\":{\"themeFont\":\"Body\"}}},\"data\":{\"dataTable\":{\"0\":{\"0\":{\"value\":\"daman\",\"style\":{\"autoFormatter\":{\"customerCultureName\":\"en-US\"}}},\"1\":{\"value\":\"sandhu\",\"style\":{\"autoFormatter\":{\"customerCultureName\":\"en-US\"}}}},\"1\":{\"0\":{\"value\":\"hello\",\"style\":{\"autoFormatter\":{\"customerCultureName\":\"en-US\"}}},\"1\":{\"value\":\"chu\",\"style\":{\"autoFormatter\":{\"customerCultureName\":\"en-US\"}}}}},\"defaultDataNode\":{\"style\":{\"themeFont\":\"Body\"}}},\"index\":0},\"Sheet2\":{\"name\":\"Sheet2\",\"selections\":{\"0\":{\"row\":0,\"rowCount\":1,\"col\":0,\"colCount\":1}},\"rowCount\":200,\"columnCount\":20,\"activeRow\":0,\"activeCol\":0,\"theme\":\"Office\",\"index\":1}}}"
Run Code Online (Sandbox Code Playgroud)