This is a much better approach of writing Hello User. It does require a few more lines of code, but it is better for modularity purposes. It is not a good practice to write everything in the Main method as I did in the previous examples.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace HelloUser
{
class Program
{
static void Main(string[] args)
{
SetConsoleTitle();
GetUserInput();
}
static void GetUserInput()
{
string strInput;
Console.Write("Enter your first name: ");
strInput = Console.ReadLine();
Console.WriteLine("Hello " + strInput);
Console.ReadLine();
}
static void SetConsoleTitle()
{
string strTitle = "Hello User 1.1";
Console.Title = strTitle;
}
}
}
Prompt for input
Write to screen
Visual c# 2008 Hello User 1.1 Console App...
Posted by
Samson J. Loo
Monday, September 15, 2008
at
9:25 AM
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment