我有一个课程如下:
public class Test
{
public int Id {get;set;}
public string Name { get; set; }
public string CreatedDate {get;set;}
public string DueDate { get; set; }
public string ReferenceNo { get; set; }
public string Parent { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我有一个Test对象列表
List<Test>testobjs=new List();
Run Code Online (Sandbox Code Playgroud)
现在我想以下列格式将其转换为csv:
"1,约翰格里沙姆,9/5/2014,9/5/2014,1356,0\N 2,斯蒂芬金,9/3/2014,9/9/2014,1367,0\N3,造雨,4/9/2014,18/9/2014,1" ;
我搜索了"将列表转换为csv c#",我得到的解决方案如下:
string.Join(",", list.Select(n => n.ToString()).ToArray())
Run Code Online (Sandbox Code Playgroud)
但是这不会根据需要放置\n,即每个对象
除了字符串构建之外还有其他最快的方法吗?请帮忙...
I have an Immutable OrderedMap as follows:
pairs: Immutable.OrderedMap({"Key1":"Value1","Key2":"Value2","Key4":"Value4"})
Run Code Online (Sandbox Code Playgroud)
I need to insert ["Key3":"Value3"] after ["Key2":"Value2"] dynamically.
I thought
pairs.MergeIn(['Key2'],OrderedMap({"Key3":"Value3"}))
Run Code Online (Sandbox Code Playgroud)
will serve the purpose but not working.
I tried
const newPairs=Immutable.OrderedMap();
newPairs.forEach(function(value,key,map)){
if(key=="Key4")
newPairs.set('Key3','Value3')
newPairs.set(key,value')
});
Run Code Online (Sandbox Code Playgroud)
But I know it's a stupid code which won't work as newPairs is immutable and newPairs will be still empty. So is there any Immutable way of OrderedMap.addBefore(Key,key,value)?