Monday, 18 July 2016

.NET(Using Visual studio 2010)

Hello Everyone!This is hitesh,I think i forgot to tell you about visual studio 2010,which we are using for programming .
You need to install visual studio 2010 or any other version to execute your program.
after installing just follow few simple steps.

1.click on the new project on the left top corner in visual studio.
By clicking that a new window will open to ask on which language you want to work.




2.click on the visual C# option 
3.choose windows
4.click on console applications.
5.Name your project(Optional)
6.You can choose the location of your project where you want to save it.
7. click OK to continue....



After that A window will open where you can Write your program.
 Here you can write your code and debug and run it.


IN the next post we'll learn about inputs Literals and taking Input from user.

comment for any query.

Thank You
Keep Coding :)
Keep Learning :)

Friday, 15 July 2016

.NET with C# chapter 2(variables and data types)

Hierarchy in Visual C#
Namespace à classes à methods
Example
System.Console.WriteLine()

Syntactical rules of Visual C#
1.    All keywords and variables in lower case
2.    All constants in capital
3.    All other items like class name, method name etc. start with capital letter

Every executable C# program must have a class with entry point
1.    static void Main()
2.    static int Main()
3.    
static void Main(string []args)
4.    static int Main(string []args)

Using Visual Studio as Rapid Application Development (RAD) tool
-         Visual Studio 2002
-         Visual Studio 2003
-         Visual Studio 2005
-         Visual Studio 2008
-         Visual Studio 2010
-         Visual Studio 2012
-         Visual Studio 2015



class First
{
    static void Main()
    {
        System.Console.WriteLine("Welcome to C#");
    }
}

Importing the namespace
Use using keyword
Example
using System;

using System;
class First
{
    static void Main()
    {
       Console.WriteLine("Welcome to C#");
    }
}

Creating shortcut or alias
Use using keyword again
Syntax
using <aliasname>=<for what>;
Example
using c=System.Console;

using c = System.Console;
class First
{
    static void Main()
    {
       c.WriteLine("Welcome to C#");
    }
}

.NET provides special built-in structures that represent common data types for all languages called as CTS (Common Type System) provide with .NET Framework as Base Class Library (BCL) provided under System namespace.
·       Byte            1 byte
·       Int16          2 bytes
·       Int32          4 bytes
·       Int64          8 bytes
·       Single         4 bytes float
·       Double       8 bytes float
·       Decimal     16 bytes float
·       Boolean     1 byte
·       Char           2 bytes
All language map these structure with their data types
C#     à     int (4 bytes)                  à Int32
VB     à     Integer (4bytes)            à Int32
using c = System.Console;
using System;
class First
{
    static void Main()
    {
        Int32 n = 5;
        c.WriteLine("Cube root of "+n+" is "+Math.Pow(n,1.0/3));
    }
}

To make program interoperable it must be CLS Compliant. CLS stands for Common Language Specifications.

Data Types in C#
Data type can be of two types
1.    Value type
2.    Reference type
All value types are alias of some structure and created on the stack.
All reference types are alias of some class and created on the heap.
Value Types
1.    byte (unsigned)
2.    short (signed)
3.    int (signed)
4.    long (signed)
5.    sbyte (signed)
6.    ushort (unsigned)
7.    uint (unsigned)
8.    ulong (unsigned)
9.    float
10.                       double
11.                       decimal
12.                       char
13.                       bool

Reference types
1.    string
a.     to hold address of some string
2.    object
a.     to hold address of any type checked at compile time
3.    dynamic
a.     to hold address of any type checked at runtime

Variable Declaration
datatype variablename;
We can also use var keyword to automatically detect type of some data and define the data type automatically also called as infer.
var n=6;

using c = System.Console;
using System;
class First
{
    static void Main()
    {
        var n = 5;
        c.WriteLine(n.GetType());
    }

}

Wednesday, 13 July 2016

Dot NET Introduction

                                           What is .NET?

A technology from Microsoft to build any kind of software using choice of language based on software called as .NET Framework.
Types of softwares
1.     Console Applications
2.     Windows Applications
3.     Web Applications
4.     Mobile Applications
5.     Window Services
6.     Web Service
Choice of language
1.     Visual C#
2.     Visual Basic
3.     Visual J#
4.     Visual F#
5.     Ruby.NET
6.     Python.NET
Etc.

Note:
All languages get compiled into a common format called as CIL (Common Intermediate Language)
.cs à CSC.EXE à .exe/.dll (CIL)
.vb à VBC.EXE à .exe/.dll (CIL)
Code written in one language can be reused in another language called interoperability among the languages or cross-language integration.


What is .NET Framework?
A software from Microsoft which provides
1.     Base Class Library (BCL)
a.     A collection of classes for almost any purpose shared by all the languages under .NET
2.     Common Language Runtime (CLR)
a.     A runtime environment to execute the CIL code
3.     Compilers and other tools

It is found under
            C:\Windows\Microsoft.NET\Framework
Versions of .NET Framework
·        1.0
·        1.1
·        2.0
·        3.0
·        3.5
·        4.0
·        4.5
·        4.6

Why dot (.) in .NET?
.NET Framework provides a platform to many languages and technologies and make joined effort better and object oriented model.
1.     VB.NET (language + framework)
2.     Python.NET (language + framework)
3.     ASP.NET (web technology + framework)
4.     ADO.NET (database technology + framework)
Hierarchy under .NET
Assemblies (.DLL/.EXE)
            Namespace
                                    Class/Structure/Enumerator/Interface
                                                Field/Method/Property/Indexer/Delegates
Example
MSCorlib.dll
            System namespace
                        Console class
                                    Write()
                                    WriteLine()
                                    ReadLine()
Example
System.Console.WriteLine("welcome to .NET")

Test Case 1: Language C#
//first.cs
class Test
{
            static void Main()
            {
                        System.Console.WriteLine("Welcome to C#");
            }
}
Compile the code
CSC first.cs à first.exe

Note:
If compiler not found set the PATH
PATH=C:\Windows\Microsoft.NET\Framework\v4.0.30319

Test Case 2: Language VB
'second.vb
class Test
            shared sub Main()
                        System.Console.WriteLine("Welcome to Vb")
            end sub
end class
Compile the code
VBC second.vb à second.exe

Using Integrated Development Environment (IDE)
è Visual Studio 2002
è Visual Studio 2003
è Visual Studio 2005
è Visual Studio 2008
è Visual Studio 2010
è Visual Studio 2012
è Visual Studio 2015

Note:
Use ILDASM.EXE (Intermediate Language De-Assembler) tool to view contents of an assembly