Remove the last character of a StringBuilder object

Updating data depending on the whether or not the parameters are set may cause various problems. For example,

StringBuilder sqlCommand = new StringBuilder();
                sqlCommand(@"update myTable set ");

                if(!String.IsNullOrEmpty(parameters.ID))
                {
                    sqlKomut.Append(" id=:ID, ");
                    command.Parameters.AddWithValue(":ID", parameters.ID);
                }
                if(!String.IsNullOrEmpty(parameters.Name))
                {
                    sqlKomut.Append(" name= :NAME, ");
                    command.Parameters.AddWithValue(":NAME", parameters.NAME);
                }

In this case, if you send only ID to set, as it will be the last parameter in the query, it may cause an  error. By removing last comma, you can add as many parameters as you want.

                //Removing commas
                sqlCommand = new StringBuilder(sqlKomut.ToString().Trim().TrimEnd(‘,’));