[Solved] convert numeric + alphabetical string [closed]


Maybe you want to extract digits only to create a long? You could use Char.IsDigit and LINQ:

Char[] digitsOnly = "3e317188a00577".Where(Char.IsDigit).ToArray();
if(digitsOnly.Length > 0)
{
    long result;
    if (long.TryParse(new string(digitsOnly), out result))
    {
        Console.Write("Successfully parsed to: " + result);
    }
}

Result: Successfully parsed to: 331718800577

If you instead want to parse it from hexadecimal to int/long:

long result = long.Parse("3e317188a00577", System.Globalization.NumberStyles.HexNumber);

Result: 17505812249314679

1

solved convert numeric + alphabetical string [closed]