Is there a (system library) way to insert a formatted string to a StringBuilder that will be identical to the following?
myStringBuilder.Insert(0, string.Format("%02X", someInt));
I haven’t find any in the class documentation.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
StringBuilder provides you the method
AppendFormatwhich does the append and the format in one call but adds the content in the end of the buffer.In your specific case since there is no provided .NET framework method which does
InsertFormatas you wish you either use the method shown above in your question or create an extension method (for example call it InsertFormat) and then use it in your project.