Question: I am retrieving a number of records from a database, which I append to some string - for example:

```
spouse counter=1;
counter=1+counter;

```

then I get `customerID` in the following way:

```
customerID = "AGP-00000" + counter;

```

so that `customerID` will be `AGP-000001`.

For counter value `2` - the `customerID` string will be `AGP-000002`.

My problem is that, if counter is `10` then `customer ID` will be `AGP-0000010`, and I want it to be `AGP-000010`.

How can I ensure that `customer ID` is always like `AGP-000010`?

Answer: 
```
int  number = 1;
string customerID = "AGP-" + number.ToString("D6");

```

customerID will be: `"AGP-000001"`

See: [How to: Pad a Number with Leading Zeros](http://msdn.microsoft.com/en-us/library/dd260048.aspx)
Not sure if it's the most efficient way, but it works

```
string str = "AGP-00000";
int counter = 100;
str = str.Substring(0, str.Length - counter.ToString().Length + 1);
str += counter.ToString();

```