Basics of .Net
Today we are going to learn Dot Net basics.
We should install Visual studio software from
Using .Net we can develop various kinds of applications.
This tutorial helps you to enter the world of development, initially we start developing our programming skills by writing console applications in Visual studio.
Lets write traditional "Hello world" program.
Steps to create a new console application in Visual Studio(VS)
start->VS-> File -> New->Project->Visual c#-> Console Application.
Here Name indicates, Project Name of your project.
Location indicates where to save the project.
Solution Name is name of your solution.(a solution is collection of project).
By looking at above image we can understand we can create various kinds of applications like,
Console Applications, Asp.Net web application, Class library, Windows Form application, WCF Service Applications etc...
Console Application : Used to create applications which run in command line environment.
Desktop Application : Used to create Desktop applications which have Graphic user interface, eg: calculator application in windows.
Web Applications : Used to create websites. eg : www.facebook.com
Also we can use any language supported by Visual Studio(C#, VB, VC++,F#..) here are using c# language to develop our "Hello World " program.
By clicking on "ok" button I will be given with default code by VS Framework which looks like this
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
}
}
}
here we use "using" keyword to add namespaces into our project, By default Framework adds some namespaces into our project, later we need to add them based on requirement.
Namespace:
A namespace is used in .NET Framework to define the scope of a set of related object. The namespace scope lets you organize code and gives you a way to create globally unique types. Whether or not you explicitly declare a namespace in a source file, the compiler adds a default namespace. This unnamed namespace, sometimes referred to as the global namespace, is present in every file.
Here I am using Write method of Console class present in System Namespace in order to display the content on the console screen.
----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication4
{
class Program2
{
static void Main(string[] args)
{
Console.Write("hello");
}
}
}
-------------------------------------------------------------------------
I ask you to practice the same by displaying your name on screen.
Now to build this application here are short cuts :
F5- Execute
CTRL+SHIFT+ B - Build
F10- Debug
F9 - Add a debug point.
Lets write an another program to add two numbers.
I expect you have basic knowledge before going ahead, if not read this article.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication4
{
class Program2
{
static void Main(string[] args)
{
int a, b;
Console.Write("Enter two numbers: ");
a = Convert.ToInt32(Console.ReadLine());
b = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("sum is : "+(a+b));
Console.Read();
}
}
}
Basics of .Net
Reviewed by Share less to Learn More
on
5:57 PM
Rating:
No comments