I decided to split up the code into two files to illustrate how to call a separate class. It is overkill for such a simple application, but it is an example!
[ Program.cs ]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace HelloUser
{
class Program
{
public static void GetUserInput()
{
string strInput;
Console.Write("Enter your first name: ");
strInput = Console.ReadLine();
Console.WriteLine("Hello " + strInput);
Console.ReadLine();
}
public static void SetGreeting()
{
string strTitle = "Hello User 1.2";
Console.Title = strTitle;
}
}
}
[ AppTest.cs ]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace HelloUser
{
class AppTest
{
static void Main(string[] args)
{
Program.GetUserInput();
Program.SetGreeting();
}
}
}
Visual c# 2008 Hello User 1.2 Console App...
Posted by
Samson J. Loo
Thursday, September 18, 2008
at
12:27 PM
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment