Is it better to use "Example1" in terms of performance? I assume that "Example2" will create a new line on the heap at each iteration, while "Example1" will not ...
Example 1:
StringBuilder letsCount = new StringBuilder("Let count! "); string sep = ", "; for(int i=; i< 100; i++) { letsCount.Append(i + sep); }
Example 2:
StringBuilder letsCount = new StringBuilder("Let count! "); for(int i=; i< 100; i++) { letsCount.Append(i + ", "); }
The .NET CLR is much smarter than that. These are " interns " string literals, so there is only one instance.
, , Append append. , , , . , , , .
.
There is actually a much faster way to do this:
string letsCount = "Let count! "; string[] numbers = new string[100]; for(int i=0; i< 100; i++) { numbers[i]=i+", "; } String.Join(letsCount, numbers);
Look here
Source: https://habr.com/ru/post/1725018/More articles:.erlang file in windows - erlangWCF: Authenticated Token Authentication Using the Basic HTTP Protocol - authenticationHow do I track a Google Alert RSS feed as if itβs happened? - monitoringAlternative makefile for windows - c ++awk save ouput command for variable - linuxDuplicating triple in RDF, authoritative look? - rdfUsing the built-in DLL? - c #Which languages ββother than Python have an explicit self? - pythonhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1725022/should-actionresult-perform-other-tasks-too&usg=ALkJrhioS66YQawFXRfuj_ML5QMjQBIEjgCan someone explain to me what the value of the logical parameter of the System.Xml.XmlDictionaryWriter.WriteNode (XmlReader, bool) method means? - xmlAll Articles