How to check and fill a string if its size is less than a condition? For example, I always need to have a string size of 8 or 9. If the string is larger I give a substring by taking only the first 9 characters. If it is smaller, I need to fill in the "0" zeros on the left. Example: '988554' should be '000988554'. Important is to keep in the string format and not convert.
int TamanhoDaString= Regex.Replace(minhaString, "[^0-9]", "").Length; //ex: tamanho 5
int QuantDeZero = 9 - TamanhoDaString; // resultado = 4
int i;
string zeros = "0";
for (i = 1; i < QuantDeZero; i++)
{
// aqui engatei, pois como vou concatenar uma string com inteiro?
//resultado teria que ser zeros = "0000"
}