get "default" text from the console

Tech-Archive recommends: Fix windows errors by optimizing your registry



Hi,
can I print some default text on the console when doing a ReadLine?

A silly example below shows two small scenarios. In the first a user
is told what he appears to be called, and asks for a name.

In the second case I want the the user to be able to just press return
to accept the username of the system. (I understand it does not work
the way I do it below - I just want to illustrate what I want).

Thanks,
P9K

---------
using System;
using System.Text;

namespace FeedMeName
{
class Program
{
static void Main(string[] args)
{
string name1 = Environment.UserName;
Console.WriteLine("Are you '{0}'?", name1);
Console.Write("name please >> ");
name1 = Console.ReadLine();
Console.WriteLine("Hello '{0}'!", name1);

string name2 = Environment.UserName;
Console.WriteLine("Are you '{0}'?.", name2);
Console.Write("name please >> ");
Console.Write(name2);
Console.CursorLeft -= name2.Length;
name2 = Console.ReadLine();
Console.WriteLine("Hello '{0}'!", name2);
}
}
}
---------
FeedMeName.exe
Are you 'per'?
name please >> my name is foobar
Hello 'my name is foobar'!
Are you 'per'?.
name please >> foobar, goddamit
Hello 'foobar, goddamit'!
---------
FeedMeName.exe
Are you 'per'?
name please >> fo
Hello 'fo'!
Are you 'per'?.
name please >> brr
Hello 'br'!

.



Relevant Pages

  • Re: Help for copying a file
    ... the optional Overwrite parameter by specifying True or False as you ... Specifying name1 is redundant. ... Try changing your f.copy name1, name2, false line to f.copy name2, ...
    (microsoft.public.scripting.vbscript)
  • Re: Mail merge 2000, 2003 difference...
    ... Word MVP web site http://word.mvps.org ... I am using a CSV generated by another company and the CSV has many ... address fields including Name1 and Name2. ... I specified that they should be on a separate line and if Name2 was ...
    (microsoft.public.word.mailmerge.fields)
  • Help on a little script
    ... ...back to the original format? ...
    (freebsd-questions)
  • Re: why is it
    ... Replace name1,name2, name3 with usenet troll names ... Now set the view so that you don't view ignored posts. ...
    (alt.games.video.xbox)
  • Re: Mappingproblem
    ... The original schema is well formed. ... <PartnerInfo> ...
    (microsoft.public.biztalk.general)