Saturday, March 5, 2016

C# - Part 1 - C# Tutorial

Part 1 - C# Tutorial - Introduction.avi

In this session:
-Basic structure of  a C# program.
-What is a Namespace.
-Purpose of Main method.

Sample Program:
//Namespace Declaration
using System;
class Pragm
{
public static void Main( )
{
//Write to console
Console.WriteLine("Welcome to PRAGIM Technologies!";
}
}
~
.NET we can use variety of programming languages.
Visual C#
Visual Basic
Visual C++
Visual F#
Using Visual C#: Create different applications.
Windows,Web,Office,Cloud,Reporting,SharePoint,Silverlight,Test,WCF,Workflow

Open Visual Studio 2010->File->New Project-Console Application.
(The programming language: Visual C#  Application:Console Application)
Project Name:IntroductionToCsharp
~
Solution 'IntroductionToCsharp'
-IntroductionToCsharp
-Properties
-References
-Program.cs
~
Program.cs:
~By default the below got created
using System
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace IntroductionToCsharp
{
class Program
{
static void Main(string[ ] args)
{
}
}
}
~
using System
class Program
{
static void Main( )
{
}
}
~
~instructor want to print a simple message through the program
start menu-run-cmd or command
~
using System
class Program
{
static void Main( )
{
Console.WriteLine("Welcome to C# Training");
}
}
~Press ctrl+F5 ( for the message to show).
--Namespace Declaration , Namespace {Class1,Class2,…}
--hover over the Console class it shows Class System.Console
--hover over System it says Namespace.System
using System
?Is Namespace a collection of classes? It is a collection of many things.
~
Using System declaration
The namespace declaration. usingSystem,indicates that you are using the System
namespace.
A namespace is used to organize your code and is collection of classes,
interfaces,structs, enums and delegates.
Main method is the entry point into your application.

~
using System
class Program
{

static void Main1( )
{
Console.WriteLine("Welcome to C# Training 1");
}

static void Main( )
{
Console.WriteLine("Welcome to C# Training");
}
}
~?Which message will be printed?
using System
class Program
{

static void Main1( )
{
Console.WriteLine("Welcome to C# Training 1");
}

static void Main( )
{
Console.WriteLine("Welcome to C# Training");
Main1( );
}
}
~

Every console application need to have a main() method.