Check range of string values that contains a number
c#
Solution
- Remove the `G` from `selectedValue`
- Parse the remaining into a `decimal`
- Implement your logic against the decimal value
var number = decimal.Parse(selectedValue.Replace("G", ""));
if (number >= 1.0m && number <= 2.5m)
{
// logic here
}
Problem
I have a list of values for example: G1, G2, G2.5, G3, G4, etc..) How can I check a range of these values in c# say if I wanted to see if value was between G1 and G2.5 ? In Vb.net I can do: ``` Select Case selectedValue Case "G1" To "G2.5" //This would be true for G1, G2, and G2.5 ``` How can I do this in c#?