Console Applications Basics


Entering In To Visual Studio.Net
  • Click on start
  • Click on AllPrograms
  • Click on Microsoft visual studio 2010
  • Steps

1] 




                                   




















 




  


(OR)
  • Click on Start                                       
  • Run
  • Type devenv
(This is exe for VS.NET & is known as Development Environment)



  
Console Application
  • Console Application do not provide any GUI facilities
  • Console applications are similar to C, C++ programs
  • In Console applications we completely work in CUI based environment
  • Console Applications are command-line oriented application

    A console application is an Windows application
    A command line program that does not require a graphical user interface.

    It allows to read characters from the console, write characters to the console and are executed in the DOS (Disk Operating System) version.

    Console Applications are written in code and are supported by the System.Console namespace. 

    Steps to create a console Application
  • Click on File
  • Click on New
  • Click on project
  • Select visual C#
  • Select Console Application template
  • Type the Application Name (CABasics)
  • Browse the location to save, Click on ok
1] 

2]
  
Note: Any project / application that we create on visual studio .NET are treated as a solution. And solution file will have a default extension of .sln.

Structure of C#.NET program

List of Class Libraries / namespaces
Namespaces Namespace name
{
   Class class name
    {
       Static void Main (string [] args)
        {
             Statements
        }
    }
}

Using
  • This Keyword is used to include any namespaces on the top of the program (In VB .Net Imports keyword is used) 
Solution Explorer
  • Solution explore is similar to windows explorer in windows. Using solution explorer we can
  • Create files / folders
  • Delete files / folders
  • Rename files / folders
  • Copy files / folders
  • Move files / folders
       Within the same solution


Program to print Welcome on the screen

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CABasics
{
    class ClsExample1
    {
        static void Main(string[] args)
        {
            Console.Write("Welcome");
            Console.Read();
        }
    }
}



output:-

 Renaming the program name or class name
  •      Go to solution explorer
  •      Select the program. cs file name

     Click with Right mouse button

  •      Click on Rename
  • Type the new name (ClsExample)


For compiling the code using C#.Net compiler use the following steps
  • Click on Build

  • Click on Build CABasics
(Or)
  • Shortcut key is Ctrl + Shift + B
This will generate exe file which contain MSIL code
For second compilation and to run our program use following steps
  • Click on Debug
  •  Click on start Debugging

  • Shortcut key is F5

No comments:

Post a Comment

Translate