-2

I have alphanumeric value = 106bd87f9386b63b. I want to convert this value into integer in c# and store the converted value into database. Is there any possibilities to convert it.

Dineshkumar P
  • 81
  • 1
  • 12

2 Answers2

2

Did you try to use this:

the strLong is a declared variable. and see this for your reference: https://learn.microsoft.com/en-us/dotnet/api/system.globalization.numberstyles?view=netframework-4.7.2

long.Parse(strLong, System.Globalization.NumberStyles.HexNumber);
Ban Tot
  • 367
  • 2
  • 9
0

You can do it with multiple methods choose one which is suitable to you
Method 1:
If you want to do it with Regex Here is Example helpful in Detail

C# Regular Expression to match letters, numbers and underscore
Here is also a useful and detailed link
Find and extract a number from a string
Other Methods:
You can also use Char.IsNumber('your character here') here is Doc link of Microsoft https://learn.microsoft.com/en-us/dotnet/api/system.char.isnumber?view=netframework-4.7.2
For the above method you have to split your string into characters and then check if it is character or not using Char.isNumber() Method .
Instead of all these you can also split this and make a function and match ASCII values and detect weather it is a number of not .
What ever method you use just detect number or not and concatinate it into a string and then at the end convert this string into a number using Convert class provided by Microsoft . Here is the detailed link of conversion How can I convert String to Int?

Ahmad
  • 770
  • 9
  • 21