From the way I understand it and from a number of articles, blogs and threads, I understand that StringBuilder is useful when one has a loop building a string and number of iterations is unknown. Recently I saw StringBuilder used when building a sql string:
StringBuilder sql = new StringBuilder();
sql.Append("SELECT Field1, Field2";
sql.Append(" FROM Table1 WHERE ID=@ID ");
So my question is - does StringBuilder has advantages over a regular String when used in the scenario above? Or it is a matter of personal preference?
Update: My question is not a general String vs. StringBuilder. I just saw a particular case in a text book that did not look particularly advantageous to me so I wanted to clarify with the experts here