Difference between revisions of "Console.Read Console.Write Demo"
m (Text replacement - "</csharp>" to "</syntaxhighlight>") |
|||
(3 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
− | [[Category: | + | [[Category:Object Oriented Programming]] |
− | [[Category: | + | [[Category:Tutorial]] |
− | |||
Start Visual Studio | Start Visual Studio | ||
Select File/New/Project | Select File/New/Project | ||
+ | |||
[[Image:OOPNewProject.PNG]] | [[Image:OOPNewProject.PNG]] | ||
Select Console Application and Name the Project | Select Console Application and Name the Project | ||
+ | |||
[[Image:OOPSelectConsoleNameProject.PNG]] | [[Image:OOPSelectConsoleNameProject.PNG]] | ||
Line 26: | Line 27: | ||
} | } | ||
} | } | ||
− | </ | + | </syntaxhighlight> |
Add the following code to make our new project similar to the HelloWorld porject | Add the following code to make our new project similar to the HelloWorld porject | ||
Line 45: | Line 46: | ||
} | } | ||
} | } | ||
− | </ | + | </syntaxhighlight> |
To build the project Select | To build the project Select | ||
Line 64: | Line 65: | ||
//Pause and wait for the user to press a key | //Pause and wait for the user to press a key | ||
Console.ReadKey(); | Console.ReadKey(); | ||
− | </ | + | </syntaxhighlight> |
<csharp> | <csharp> | ||
Line 89: | Line 90: | ||
} | } | ||
} | } | ||
− | </ | + | </syntaxhighlight> |
+ | |||
+ | |||
+ | The final output should look like this | ||
+ | <pre class="console"> | ||
+ | What is your name? Jeff | ||
+ | Hello Jeff | ||
+ | </pre> |
Revision as of 18:28, 25 January 2016
Start Visual Studio
Select File/New/Project
Select Console Application and Name the Project
You should see the following Code in the project
<csharp>
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleRead {
class Program { static void Main(string[] args) { } }
} </syntaxhighlight>
Add the following code to make our new project similar to the HelloWorld porject
<csharp> using System; using System.Collections.Generic; using System.Text;
namespace ConsoleRead {
class Program { static void Main(string[] args) { Console.Write("Hello"); } }
} </syntaxhighlight>
To build the project Select
or
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
<csharp> Console.Write("Hello");
//Pause and wait for the user to press a key Console.ReadKey();
</syntaxhighlight>
<csharp> 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(); } }
} </syntaxhighlight>
The final output should look like this
What is your name? Jeff Hello Jeff