Created
May 22, 2017 20:12
-
-
Save aramkoukia/a6a178fe8ee04aa107bc4c5b870ffce6 to your computer and use it in GitHub Desktop.
StringBuilderVsStringInterpolation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class StringBuilderVsStringInterpolation | |
| { | |
| private string data1; | |
| private string data2; | |
| private string data3; | |
| public StringBuilderVsStringInterpolation() | |
| { | |
| data1 = Guid.NewGuid().ToString(); | |
| data2 = Guid.NewGuid().ToString(); | |
| data3 = Guid.NewGuid().ToString(); | |
| } | |
| [Benchmark] | |
| public string StringBuilder() => (new StringBuilder()).Append("test format").Append(data1).Append(data2).Append(data3).ToString(); | |
| [Benchmark] | |
| public string StringInterpolation() => ($"test format{data1}, {data2}, {data3}"); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment