Question: I have a string which comprise lots of letters. I have used the following code to convert it to numbers, but the new string **t** still gives me imperfect result.
For example:

> 
> tung2003 -> -1-1-1-12003
> 
> 
> **What I expected:** 1161171101032003 (116 is the ASCII code of **t**, 117 is the ASCII code of **u**
> 
> 
> 

```
string t=null;
foreach (char c in Properties.Settings.Default.password)
{
      int ascii = (int)Char.GetNumericValue(c);
      int counter=0;
      counter = ascii;
      t = t + Convert.ToString(counter);
}

```

The problem is the **-** character. I want my new string only comprises numbers.

Answer: 
It looks like you do *not* want the ASCII values of the numbers based on your expected output. In that case you can just do something like this:

```
string input = "tung2003";

string output = string.Empty;

foreach(char c in input)
{
    if(char.IsNumber(c))
    {
        output += c;
    }
    else
    {
        output += ((byte)c).ToString();
    }           
}
//output is now: 1161171101032003

```

Fiddle [here](https://dotnetfiddle.net/5lnr1w)
Extrapolating your output it looks like you want two different things. You want to tally each ascii character as long as it is a letter and extract the numeric values to append. The following provides three options, the first is to tally the ascii values from letters and the other two are ways to extract only digits. Because your code example uses a Password I am assuming you are trying to do some sort of custom hashing and if that is the case you should use a Hash implementation from the Cryptography namespace or some other package.

```
using System;
using System.Linq;
using System.Text.RegularExpressions;

namespace ConsoleApp5
{
    class Program
    {
        static void Main(string[] args)
        {
            var combined = OnlyLettersToAscii("tung2003") + OnlyNumbers("tung2003");

            Console.WriteLine($"Input: tung2003 Output: {OnlyNumbers("tung2003")}");
            Console.WriteLine($"Input: tung2003 Output Regex: {OnlyNumbersWithRegex("tung2003")}");

            Console.ReadKey();
        }

        private static string OnlyLettersToAscii(string originalString)
        {
            if (string.IsNullOrWhiteSpace(originalString)) return originalString;

            return string.Join(string.Empty, originalString.ToArray()
                .Where(w => char.IsLetter(w))
                .Select(s => ((int)s).ToString()));
        }

        private static string OnlyNumbers(string originalString)
        {
            if (string.IsNullOrWhiteSpace(originalString)) return originalString;

            return new string(originalString.Where(w => char.IsDigit(w)).ToArray());
        }

        public static string OnlyNumbersWithRegex(string originalString)
        {
            return Regex.Replace(originalString, @"[^\d]", string.Empty);
        }
    }
}

```