SystemExt/Terminal/Prompt.cs
/// <summary>
/// Prompts the user to enter a float answer to a question.
/// </summary>
/// <param name="question">
/// The question to ask the user.
/// </param>
/// <param name="defaultValue">
/// The answer to return if the user just presses enter.
/// </param>
/// <param name="min">
/// The minimum possible value.
/// </param>
/// <param name="max">
/// The maximum possible value.
/// </param>
/// <returns>
/// The response given by the user converted to a boolean.
/// </returns>
Prompts the user to enter a float answer to a question.
Prompts the user to enter a float answer to a question .
public static double Float(string question, double defaultValue = 0, double min = long.MinValue, double max = long.MaxValue)
        {
            while (true)
            {
                var input = Prompt.String(question, defaultValue.ToString(CultureInfo.InvariantCulture));
                double result;
                if (!double.TryParse(input, out result) || result < min || result > max)
                {
                    Console.Error.WriteLine("You must enter a valid decimal number between {0} and {1}.", min, max);
                    continue;
                }
                return result;
            }
        }
public static double Float ( string question , double defaultValue = 0 , double min = long . MinValue , double max = long . MaxValue ) { while ( true ) { var input = Prompt . String ( question , defaultValue . ToString ( CultureInfo . InvariantCulture ) ) ; double result ; if ( ! double . TryParse ( input , out result ) || result < min || result > max ) { Console . Error . WriteLine ( " " , min , max ) ; continue ; } return result ; } }
Prompts the user to enter a float answer to a question.
Prompts the user to enter a float answer to a question .
The response given by the user converted to a boolean.
The response given by the user converted to a boolean .
question
string
The question to ask the user.
The question to ask the user .
defaultValue
double
The answer to return if the user just presses enter.
The answer to return if the user just presses enter .
min
double
The minimum possible value.
The minimum possible value .
max
double
The maximum possible value.
The maximum possible value .