c# - Using Zip to combine 3 strings instead of 2 -
i'm writing function add new nodes xml file, created 2 list<string> , combined them following
var firsttext = firstlist; var secondtext = secondlist; var alltext = firsttext.zip(secondtext, (t1, t2) => new { firstword = t1, secondword = t2 }); foreach (var tt in alltext) { xml.writestartelement(tt.firstword); xml.writevalue(tt.secondword); xml.writeendelement(); } to add this
<force>true</force> <auto>false</auto> right want combine 3 strings instead of 2 writing this
xml.writestartelement(tt.firstword); xml.writestartelement(tt.secondword); xml.writevalue(tt.thirdword); xml.writeendelement(); xml.writeendelement(); so xml like
<settings> <force>true</force> </settings> <settings> <auto>true</auto> </settings> how can such thing?
just call .zip again:
var alltext = firsttext.zip(secondtext, (t1, t2) => new { firstword = t1, secondword = t2 }); .zip(values, (t12, v) => new { firstword = t12.firstword, secondword = t12.secondword, thirdword = v }); you
Comments
Post a Comment