AddOptionList Help needed

I am working on wrapping my head around C# and decided to make a simple utility command that has just 1 list of options to pick from. One of the options in that list (the very last one) is “Custom”
What I want is when someone clicks on that option it just asks for a double input, hit enter I would check to make sure the double is > 0 and it keeps going with the rest of the command if not just loop until we get a valid number.

I have the list overall looping and working right, but I can’t seem to find a way on “custom” click to let me get a double correctly.

I’ve tried doing stuff several different ways, clearly not successfully, the last attempt was to go into get mode, but that’s not working either and doesn’t feel like it would be the way to do it anyways.
Any suggestion would be super helpful

Here is the chunk of code that pertains to the issue hope it helps to identify a solution.

			//Initiate Get Object command
			var go = new GetObject();
			go.SetCommandPrompt("Select Closed Objects");
			//go.EnablePreSelect(true, true);
			go.GeometryFilter = ObjectType.Brep;

			// List of Material Names
			string[] mtlType = new string[] { "Mild_Steel", "Aluminum", "Stainless_Steel", "Glass", "Custom" };
			// List of Desities in the same order as Materail Names
			int[] mtlDensity = new int[] { 490, 169, 495, 158, 1 };
			// Set default index values
			int listIndex = 0;
			// Create a density variable and set it to whatever the defaults are in this case Mild_Steel - 490 lb/ft^3
			double density = mtlDensity[listIndex];
			// Add list to CMD
			int optList = go.AddOptionList("Material", mtlType, listIndex);
			
			while (true)
			{

				GetResult res = go.GetMultiple(1, 0);
				
				if (go.CommandResult() != Result.Success)
					return go.CommandResult();


				if (res == Rhino.Input.GetResult.Object)
				{

					// Check if custom option is selected 
					if(mtlType[listIndex] == "Custom")
					{
						// This will set density to 1 based on Density list just something to start with
						//density = mtlDensity[listIndex];
						// Need to get a custom input from user
						RhinoApp.WriteLine("Custom: {0}", density);

					}
					else
					{
						// Density will be set based on the selection list via looking up the corresponding int in a Density list
						density = mtlDensity[listIndex];
						RhinoApp.WriteLine("Reg: {0}", density);
					}
				}
				else if (res == Rhino.Input.GetResult.Option)
				{
					if (go.OptionIndex() == optList && go.Option().CurrentListOptionIndex != Array.IndexOf(mtlType, "Custom")) // maybe add in here AND NOT CUSTOM type thing | listIndex != 4  | mtlType[listIndex] != "Custom"
						listIndex = go.Option().CurrentListOptionIndex;
					else
					{						
						while (true)
						{
							RhinoGet.GetNumber("Custom Density:", true, ref density);
							if (density <= 0)
							{
								// Warn that it cannot be less than 2
								RhinoApp.WriteLine("Density must be more than 0");
								continue;
							}
							break;
						}


					}

					continue;
				}

				break;
			
			}

Why not just using another overload of GetNumber method witch let you determine lower and upper limits:
Mikhali

protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
    var go = new GetObject();
    go.SetCommandPrompt("Select Closed Objects");
    go.GeometryFilter = ObjectType.Brep;
    var mtlType = new[] { "Mild_Steel", "Aluminum", "Stainless_Steel", "Glass", "Custom" };
    var mtlDensity = new[] { 490, 169, 495, 158, 1 };
    var listIndex = 0;
    var density = (double)mtlDensity[listIndex];
    var optList = go.AddOptionList("Material", mtlType, listIndex);
    while (true)
    {
        var res = go.GetMultiple(1, 0);
        if (go.CommandResult() != Result.Success)
            return go.CommandResult();
        if (res == GetResult.Object)
        {
            if (mtlType[listIndex] == "Custom")
                RhinoApp.WriteLine($"Custom: {density}");
            else
            {
                density = mtlDensity[listIndex];
                RhinoApp.WriteLine($"Reg: {density}");
            }
            break;
        }
        if (res != GetResult.Option || go.OptionIndex() != optList) continue;
        listIndex = go.Option().CurrentListOptionIndex;
        if (go.Option().CurrentListOptionIndex == Array.IndexOf(mtlType, "Custom"))
            RhinoGet.GetNumber("Custom Density", false, ref density, 2, double.MaxValue);
    }
    return go.CommandResult();
}

Mikhail.zip (101.3 KB)