c# - How can you minimize the number of new lines of code (not using a string class methods)? -
private static void main() { var stringsone = new[] {"aaa", "bbb", "ccc"}; var sb = new stringbuilder(); foreach (var s in stringsone) { sb.append(s + " "); } var concat = sb.tostring(); console.writeline(concat.substring(0,concat.length-1)); console.readkey(); }
you can try this, minimized lines:
var stringsone = new[] { "aaa", "bbb", "ccc" }; var sb = new stringbuilder(); stringsone.select(p => p).tolist().foreach(q => sb.append(q+" ")); console.writeline(sb);
no tostring or substring method used
Comments
Post a Comment