Go to Content
Columbia College Chicago
IAM Wiki: Console.Read Console.Write Demo
Home IAM Home IAM Wiki Console.Read Console.Write Demo    | Log in
Console.Read Console.Write Demo

Start Visual Studio

Select File/New/Project

Image:OOPNewProject.PNG

Select Console Application and Name the Project

Image:OOPSelectConsoleNameProject.PNG


You should see the following Code in the project

 
using System;
using System.Collections.Generic;
using System.Text;
 
namespace ConsoleRead
{
    class Program
    {
        static void Main(string[] args)
        {
        }
    }
}

Add the following code to make our new project similar to the HelloWorld porject

 
using System;
using System.Collections.Generic;
using System.Text;
 
namespace ConsoleRead
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write("Hello");
        }
    }
}

To build the project Select

Image:OOPSelectStartDebug.PNG

or

Image:OOPPressPlay.PNG

You should a black console window flash on the screen and really quicly display the word 'Hello'

Add the following lina after the Console.Write Line

 
Console.Write("Hello");
 
            //Pause and wait for the user to press a key
            Console.ReadKey();

 
using System;
using System.Collections.Generic;
using System.Text;
 
namespace ConsoleRead
{
    class Program
    {
        static void Main(string[] args)
        {
            string strName;     //Declare a string object
            
            Console.Write("What is your name? ");
            strName = Console.ReadLine();   //set strName value equal to what the user typed
            
            Console.Write("Hello " + strName);
 
            //Pause and wait for the user to press a key
            Console.ReadKey();
        }
    }
}


The final output should look like this

What is your name? Jeff
Hello Jeff
This page was last modified on 4 August 2008, at 20:52. This page has been accessed 858 times. About IAMMediaWiki Powered by MediaWiki