So I want to extract the value from a string the value will place at the right after my specific character in this case my specific character is - and will place at the right.
The string will look like this:
TEST-QWE-1
TEST/QWE-22
TEST@QWE-3
TEST-QWE-ASD-4
And from that string I want to extract
1
22
3
4
How I do that in C#? Thanks in advance
mystring.Substring(mystring.IndexOf("-") + 1)
Or use LastIndexOf in case there are other dashes before the last part:
mystring.Substring(mystring.LastIndexOf("-") + 1)
Substring: https://learn.microsoft.com/en-us/dotnet/api/system.string.substring?view=netframework-4.7.2
LastIndexOf: https://learn.microsoft.com/en-us/dotnet/api/system.string.lastindexof?view=netframework-4.7.2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With