Sample programs in C#.NET
Lets us see one sample program which can utilize
System.Console class
Console is class which contains input and output possible methods and it is in System namespace
Console is class which contains input and output possible methods and it is in System namespace
Steps to write and execute a sample programs
Step 1 : open visual studio 2012
Step 2 : goto file
=> new = > project
Step 3 : select C# language , select .NET framework 4.5 and select “console
applicatiom ” template .
Step 4 : Write project name as ConsoleDemo and click OK
Step 5 : Write the following code shown below
using System; // importing section namespace ConsoleDemo2 // namespace begining { class Program // a class begining { static void Main(string[] args) // method begining { Console.Write("hi ,"); Console.WriteLine("Mr. DOTNET "); Console.WriteLine("hello C#.NET");// prints output black screen Console.ReadKey(); // it awaits until we press any single screen } } }
Step 6: Now build the project by going to BUILD menu select Build Solution and Click STARTStep 7: If the code have no error . it will shows the output as belowConsole class methods and properties
Methods :
- write() : It prints characters to the black screen
- WriteLine() : It prints characters to the black screen and moves cursor to new line
- Read() : It reads a character from screen and written ASCII value of the char
- ReadLine() : It reads a string value and returns string
- ReadKey() : It reads a single character or it waits for taking single character
- Clear() : it wil clears black scree
- Beep() : it gives beep sound
Properties :If you want see remaining methods and properties while write Console. and press ctrl+space
- backGroundColor
- foreGroundColor
- title
- windowSize
- cursorSize etc.,
the intelligence shows remaining methods and properties
Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
ReplyDeletec net training in electronic city