Question: string str="75,75,83,84" 

I want to remove repeating values from the string, I provide one example of a string.`string str+=Id.ToString() + ",";`

Answer: 
You can use [`string.Split`](https://learn.microsoft.com/en-us/dotnet/api/system.string.split?view=netframework-4.7.2) to split the string into separate values, e.g.

```
var input = "75,75,83,84";
var values = input.Split(',');

```

Afterwards, you can remove duplicates from the values using [`Enumerable.Distinct`](https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable.distinct?view=netframework-4.7.2), e.g.:

```
var distinctValues = values.Distinct();

```

Then you can use [`string.Join`](https://learn.microsoft.com/en-us/dotnet/api/system.string.join?view=netframework-4.7.2) to join the string again, e.g.: 

```
var output = string.Join(",", distinctValues);

```
You could try something like this:

```
String foo = "10,10,50,22,12";
String[] fooInPieces = foo.Split(',');
foo = '';
List<string> fooNoDuplicate = new List<string>();
foreach (string piece in fooInPieces) {
    bool noDuplicate = true;
    foreach (string doublePiece in fooNoDuplicate) {
        if (doublePiece.replace(',', '') == piece.replace(',' '')
            noDuplicate = false;
    }
    if (noDuplicate){
        fooNoDuplicate.Add(piece);
        foo += piece;
    }
}

```

*String.replace(',', '')* makes sure that the last digits can't be duplicates, since they're always different (no comma at the end).

*String.split(',')* turns the digits into pieces whenever it finds a comma.
You then start adding the pieces to *fooNoDuplicate* (the length of a list doesn't need to be defined). You can then check if the same variable already exists within the list before adding.