0

What Culture should I use with StringBuilder.Append to have similar functionality to this code:

StringBuilder sb = string.empty; string str = ...; sb.Append($"{str}BLABLA\n"); 

Is it really possible that I get different results depending on the Culture here, as Visual Studio claims when throwing out error CA135? It seems doubtful because I'm only using a string within the string interpolation.

I'm almost tempted to simply replace the call with two calls to Append to get rid of this...

2
  • 2
    That's a false warning. The poster of this issue has a very good point, sad they didn't take them serious. Commented Sep 23, 2024 at 17:40
  • Thank you for your answer. I'm still quite confused by this Culture stuff.. I can't find a definitive answer about what Culture I should use in this case to preserve functionality, but based on your answer and my initial assumption, it might be the case that any Culture would work here. I don't really know if it's worth adding that Culture parameter in the code, I think I'd rather just use two Append calls, one with str, one with the fixed part. Suppressing the warning does not seem like a good call in case someone uses something other than a string in the interpolation in the future. Commented Sep 24, 2024 at 7:40

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.