Tuesday 21 January 2014

Reading and writing to a console in C#

                                                                                                                                       Precious......
                                                                                                                                                    Next......



In this session we will learn Basic structure of a C#  programme.
In part 1  we simply print a message by using "Console.writeline" keyword. But in this part we print a message which is printed by user. If  user print  "NetQube" then it return "Hello NetQube".

Two ways to write to console
     a) Concatenation
     b) Place holder syntax – Most preferred 



Code samples used in the demo


using System;
class Program
{
    static void Main()
    {
       
        Console.WriteLine("enter your name");
        // Read the name from console
        string UserName = Console.ReadLine();
        // Concatenate name with hello word and print
        Console.WriteLine("Hello " + UserName);  // here UserName should be same because C# is a case sensitive 
        //Placeholder syntax to print name with hello word 
        //Console.WriteLine("Hello {0}", UserName);
       // here {0} is a place holder when we print user name then it substitute at {0} position
    }
}


We can Better understand by using another example
using System;
class Program
{
    static void Main()
    {
       
        Console.WriteLine("enter your FirstName");
        string FirstName = Console.ReadLine();
         Console.WriteLine("enter your  SecondName");
         string SecondName = Console.ReadLine();
        Console.WriteLine("Hello " +  FirstName , SecondName); 
        //Placeholder syntax to print name with hello word 
        //Console.WriteLine("Hello {0} , {1}", FirstName , SecondName);
       
    }
}


                                                                                                                                       Precious......
                                                                                                                                                    Next......






Ado.net Tutorial

Ado.net  tutorial for beginners, and experienced programmers. These tutorials, which start from the very basics and covers advanced concepts. 
Previously i explained about basic concept on interview questions on Ado.net  Here i will explain practical knowledge on Ado.net  for  those   who need it. If any one have any query then leave a comment and if you like it then share with your friends on facebook.



Ado.net Tutorial Will Coming Soon

If you have any problem regarding Asp.net you can leave comment.
Asp.Net Tutorials

What is asp.net

Here i will explain ,what is asp.net and why we use asp.net

Asp.net First web application

In previous article we learned What is asp.net ,here we will learn how to create first web application in asp.net

Code-Behind for Web Application Projects

In previous Article we created a web application using asp.net ,but we didnt handle any asp control using code , here we will learn how to work on code behind (.cs) file in asp.net

Export data from sqlserver database to excel in asp.net

Here we will learn how to export data from SQL Server to Excel in asp.net

SQL SERVER Tutorial

SQL SERVER  tutorial for beginners, and experienced programmers. These tutorials, which start from the very basics and covers advanced concepts. 
Previously i explained about basic concept on interview questions on SQL SERVER  Here i will explain practical knowledge on SQL SERVER  for  those   who need it. If any one have any query then leave a comment and if you like it then share with your friends on facebook.



SQL SERVER Tutorial Will Coming Soon

If you have any problem regarding Asp.net you can leave comment.

C# program Selection Sorting

Selection sort is a straightforward sorting algorithm. This algorithm search for the smallest number in the elements array and then swap i...