Hello,
i have to write double and float values at each time together to a line in a textfile on sdcard.
But the saving process or the sum of the values in one line takes too long.
I believe that the ToString method takes too long to convert the values.
Is there a solution without using ToString, and still save line by line? For Example without saving a string but another format?
I’m not sure if this is of any help or faster. But if the format of the data is not that important. I use an object with the [Serializable()] annotation to store the information and then write to the SD card using:
in .NET Strings can not be extended in length. This is why the whole string needs to be re allocated on every + operation.
So you should consider using StringBuilder to build strings.
Internally StringBuilder uses a char array which gets extended if needed.
You also can reserve capacity in advance by choosing the correct constructor (if you know the final length more or less exact).
So this might look like this:
var sb = new StringBuilder(20);
sb.Append("Hello");
sb.Append(' ');
sb.Append("World");
var str = sb.ToString();