How to set default input value in .Net Console App?

前端 未结 8 1399
时光取名叫无心
时光取名叫无心 2020-12-11 16:01

How can you set a default input value in a .net console app?

Here is some make-believe code:

Console.Write("Enter weekly cost: ");
string inp         


        
8条回答
  •  [愿得一人]
    2020-12-11 16:46

    There's a much better way to do this now, check out Readline on nuget: https://www.nuget.org/packages/ReadLine

    1. install-package Readline
    2. var input = ReadLine.Read("Enter weekly cost: ", "135");

    I like to use the console to write interactive tests, and having default values can really help things.

提交回复
热议问题