Tuesday, 23 January 2018

002 C# Introduction

C # tutorial introduction 
C # is and types safe environment for better programming , developed by Microsoft as a part of
.Net framework. C# was developed by Anders Hejlsberg for Microsoft .Net Framework. It was later approved 
by ECMS and ISO. C Sharp is more type safe then C ++. We can build software like 
  • XML web service
  • Client server application 
  • Database application 
  • Web application 
  • Console application 
  • WCF application 
  • WPF applications and many more. 

.Net Framework is a managed type safe environment for software development and execution of the
 software. It allocate memory and grant permission for execution of the software. .Net Framework 
also support cross language compatibility. .Net component can communicate with each other even 
if component has written in different language. This type of communication is safe got by CTS common 
type specification.  C# also do automatic memory management and garbage collection.
.Net Framework consists of 4 languages. Among these 4, C# is the most Preferred language
 among the developers, for its beauty and simplicity and also easy to learn. C# is very powerful 
but simple programming language for building interoperable, scalable, robust application. Web service 
is easy to build C # and can we consume Web service from any platform. WCF Service also can be
consumed by any platform in the world. 

C # is object oriented language , features of OOPS supported
  • Class 
  • Object 
  • Inheritance 
  • Interface 
  • Polymorphism 
  • Data encapsulation 
  • Data Hiding 

Here is the list of component of .Net framework 
  • Common language specification 
  • Common language runtime 
  • .Net Framework class library 
  • Common type system 
  • Assemblies 
  • Windows forms 
  • ASP.NET 
  • Windows Communication Foundation 
  • Windows presentation Foundation 
  • Language integrated query 
  • Windows workflow Foundation. 

Before we go to the above following points, you should consider some topic of .Net Framework also

 Microsoft intermediate language(MSIL) :  Microsoft intermediate language also called intermediate 
language. While compiling a  program source code, Microsoft convert to a intermediate code. This 
intermediate code also includes instruction for loading storing information also.

Just in time compiler : A compiler which convert the intermediate language to machine language is 
called just in time compiler. This two step process, fast the source code is converted to intermediate 
language, then this intermediate language is converted to machine code. In the first step the source 
code is convert it to a byte code. This is called common language run time or intermediate language.
 In the second step the intermediate language is converted to machine instruction bye just in time 
compiler. 

Common type specification : Common type specification is a standard to represent specific 
type of value in the memory. Program written in different language can communicate with 
each other with standard with this stand. Example a type defined, a set of value define, 
now they can communicate with each other. Let the type defined as integer, they can 
communicate with each other and add, sum operation can be done. 

.Net class library : .Net class library is a collection of classes an interface and objects
 which provides the manage type safe development. .Net classes support inheritance which 
is base class and inherited class. Dot Net base class for safe development. Namespace is a
 is logical grouping of classes, we use those namespace only which class is
 required for the development , system is the base class which is required for any development. 
Because all preliminary functions and services are available in the System class. 
System.Data is a class which is child class of system, all data related services are incorporated 
in the System.Data class. We can do data access insert, update ,delete function and services are 
available in the system the data class. 

Here are some usable classes of .Net framework. 

System : This class is the root of all classes and all service preliminary stay in this classes. 
The preliminary data type and this are available in the system class. 

System.collection : This namespace is for memory management related to 
collections. The collections are array, array list, stack ,queue ,list, dictionary object 

System.Data : This namespace content class and services which are useful for data access and 
data manipulation. For example if we want to insert update or delete data, we need to add 
system.data namespace in our application. 

System.Data.oledb : This namespace are required to Oledb data. For example we can 
data handle with Microsoft access and excel with this namespace.

System.Data.SQLclient : Microsoft SQL server is a well-known database and is widely used. 
We can do data manipulation and access data with the help of this class. 

System.IO : File management such as read write edit file is very common for software developer, 
reading writing and editing file can be handled with the help of System.IO class. Every necessary 
service related to file management are available in this namespace. 

System.Math : Common mathematical functions and related service are available in this namespace. 
Example Sum,delete, random number are available in this namespace. 

System.Drawing : This is the namespace used for graphics in.Net framework. For example if i want to 
draw a line , I would use system to System.Drawing. Very simple an easy way to design and graphic 
object. 

System.Threading: .Net is a smart framework, operated on Windows platform, Windows 
operating system , .Net Framework both support multi threading process, the namespace help to 
develop the engineer multi threading applications with the help of this namespace. 

Assembly : Assembly is it self describing collection of program which help.Net to run smoothly.
 An assembly manifest is a part of assembly which store assembly name, version other
information about the assembly. Security instruction permission required also store in assembly 
manifest. Some other assembly, related information and there details are stored in the Assembly 
manifest. 

Satellite is a single application application, depending upon the call, resource file 
compile into the satellite assembly. Satellite assembly detect the user culture and load the 
corresponding string from assembly during run time . 

Windows form applications : A general purpose application for client server application, generally 
an application connected with a database for input and output purpose. In this application a graphical 
format, where user input is data is called win Windows form .

ASP.NET : An application which run on web web platform, for example www, http, https platform. 
Maybe it will be a client server application, maybe it is an method exposed to Web. 
That is web service. Web service development and consume also a part of ASP.NET. 

WCF : Windows Communication Foundation is an Technology which can communicate author 
platform through a channel. Specific data contract, data member , interface are required for 
communication through WCF channel. 

Language integrated query : It is a good features recent .Net framework , that is database query 
can be written in front end source code. The most popular implementation of the language integrated 
query is with entity framework, Microsoft Enterprise practice library.

Here is some more topics
Manage code : Any code written by .Net language within the .Net Framework is call manage 
code. C#, VB.Net and other .Net language are example of manage code. .Net Framework 
familiar with this languages and compiler compile this with manage code execution. 

Unmanaged code : Any code written by and which does not supported by .Net compiler is called 
unmanaged code. Its means, any language out of .Net Framework languages quotes are 
unmanaged..Net Framework does not know these languages and have no control over the
application written by this languages. 

Here are the example of manage and unmanaged code 

Manage code : C ,C plus plus, Window 32 API component 
Unmanaged code : VB.Net, C Sharp, G sharp, Js script


Monday, 22 January 2018

001 C# Introduction to Object Oriented Programming

C# tutorial 001 

Introduction to Object Oriented Programming

Technological world is dynamic . New tools and Technology coming day by day , and this
process is vast. Software Industry also come under the process , new tools and 
technologies are coming to meet common people requirement, to make life easier to easier and
and removing the manual job with machine made work .The fast changing world made software 
industry in a crisis . The most challenging work is to represent an entity which match with the 
real life world , to improve quality of software and to design a software which can communicate
with other software technology and and communicate cross platform Technology . During design a
software engineer consider some following basic points 

  • User friendliness 
  • Security and integrity
  • Correctness 
  • Usability 

Object oriented programming like C + + , C # treat data as an element who is cannot 
free flow to the program . Object oriented programming bind data functions together
 which is called class . A data can be accessed by only the function associate with it . 
No other object function class or system know the internal structure of the objects . This method
 is called data binding . When we try to modify the data or access the data ,it can call only
by the functions . When two objects communicate between each other , without knowing the 
internal structure of each other , they called only functions associate with the other object . 
This is called data hiding . The following points are important to understand the concept of oops

  • Objects 
  • Function 
  • Classes 
  • Inheritance 
  • Polymorphism 
  • Dynamic binding 
  • Message passing 
  • Data abstraction and encapsulation 
  • Variable initialization

 objects : objects  is an run time   basic entity  of an  object oriented system .  An object    
content data and function associate with the data . An object can be anything to represent
a real life world . Car , student ,   football , computer anything . Example of an object.

public class Student
{
public string Name { get; set; }
public int Age { get; set; }
public Student(string name, int age)
{
Name = name;
Age = age;
}
//....other function and methods
}



functions : Function is an  system define programming which can access data of an object .
 It not only access the data , can communicate  with other object also. Functions and heart of  
OOPS concept . Function can have different accessibility modifier depending upon
 the requirement . It can be private , public , protected , friend . Depending upon the requirement 
to match of the real life world  , software engineer   define  the accessibility modifier of  a 
function . 

classes  : We already discussed that an object contain data and the functions ,the interstate 
of code which is the system we define is called class . Once a class is defined we
 can create any number of instance of an class .Thus a class is a collection of objects of similar
 types .

public class Student
{
public string Name { get; set; }
public int Age { get; set; }
public Student(string name, int age)
{
Name = name;
Age = age;
}
//....other function and methods
}
 


Inheritance : Inheritance is a property which can acquire the property of other class . A class 
name x , another class name y , we can derive the property of x to y , bye inheritance . 
We just need to tell the class who it is its parents class . Entire property of x will be drive to 
y or automatically . 



Polymorphism : Polymorphism means more than one forms . And operation can be exhibit
 different behavior on different instance on different situation . For a simple example , if we call
 a function parameter with a single string object , it will call the function which has only string 
parameter . Maybe there function with different parameter with same name , function with 
same signature will be called and execute .

There are two types of polymorphism static or compile time polymorphism and dynamic 
or runtime polymorphism .In static static polymorphism the method which will be called 
as decided during the compile time.Oveloding is the best example of static polymorphism .
This type of polymorphism compiler check the Parameter type number during compile time .

Runtime polymorphism which is called method overriding method overriding is a technique to 
overide the base class to derived class.This type of polymorphism compiler does not know 
the type and the parameter during compile time , at runtime it will be decided ,which method
will be called .If may match then execute or through error.It is called dynamic binding .

class Student
{
    public class OverloadTest
    {

        public void Getdata(string a1, string a2)
        {
            Console.WriteLine("Adding Two String :" + (a1 + a2));
        }

        public void Getdata(int a1, int a2)
        {
            Console.WriteLine("Adding Two Integer :" +( a1 + a2));
        }

    }

    static void Main(string[] args)
    {
        OverloadTest obj = new OverloadTest();

        obj.Getdata("Hello ", "World");

        obj.Getdata(5, 10);

        Console.ReadLine();
    }
}



Message passing : object oriented programming is object base , it is the heart of the 
approach . Object to object communication is also necessary . Object can communicate with
 other object by passing passing message as the real human does. 

Benefit of object oriented programming as follows 
  • Complexity software development can be easily handled .
  • Future enhancement and development of father recruitment can be easily options .
  • We can build a small software to a lot software gradually without affecting the user regular work .
  • Data partition help us to keep data secure from other objects .
  • Message passing can communicate between objects to object which meets the real life world activity .
  • Redundant code of existing system can be eliminated.
  • Real time system can be developed with large data.

Tuesday, 1 November 2016

Asp.Net Catching

Catching is a technique to get frequently used data/ Information /pages instantly without re-processing web page from server.The object is stored in cache memory and deliver to browser when asked , this makes first operation & less load on server . To generate new HTML & data , is costly for server and it is also time consuming also , bit if stored in memory , retrieve data will be much more efficient than retrieve from database.That is the utility of catching .For example , we are developing an e commerce application , price list of item will not change daily , may be change once in a week.Now if we put the price list in catching , then e commerce site will work much faster.Generating a web page need several stage Page request, Page Initialization , Load , validation , rendering , unload new connection establishment with database , query execution , fetching data.But catching , just retrieve data from cache .Net framework in run time key-value map CLR object called cache .A catching is effective till
  • The catching lifetime , whcih has expired
  • The application has released memory
  • In any case ,catching fails
There are three type of catching in Asp.net Output catching , data catching , object catching. The scope of the data catching is within the application domain ,Catching comes under System.Web.Caching namespace .One point to remember , we can clear browser history to clear cache .Cache can be removed cache remove command

Cache.Remove("MyChache");


Output Catching : Output catching stored finally rendered HTML copy to cache memory.It is simple in implementation and very efficient in working .Output catching reduced response time and work still cache expires. @ OutputCache is the directive to declare output catching , several parmeter are there to maintain catching .For example

HTML
 
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ OutputCache Duration="100" VaryByParam="None" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
   
        <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
   
    </div>
    </form>
</body>
</html>

 C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Threading;
public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Thread.Sleep(1000);
        Response.Write("This page generated and cached at:"+System.DateTime.Now.ToString());
    }
    protected void Button1_Click(object sender, EventArgs e)
    {

    }
}

Runtime



 In the above example , page generation time is same , when we click on the button , the page is not re created in server , it is being server by catching after the very first time.

Data Caching : It is a technique to catch the data at the end . Data catching is effective as the previous condition satisfied .
  • The catching lifetime , which expires
  • The application released memory
  • In any case , catching does not occurred
Object Catching : Object catching is the catching a object from web page .Catching an object of an page is much more efficient than catch the entire page.Objects catching can catch complex object also .Still now we came to know , what is catching , type of catching and how catching works .Now we will go though parameter & configuration related to catching .First we will learn that .How we can control where catche can be stored .We can define it .The attribute is HttpCacheability.


HttpCacheability.Server :It tells that , the cache can be store any location /client /host/Proxy.

HttpCacheability.ServerAndNoCache :The response is catche at server & client and not any other location like proxy server.

HttpCacheability.Private :It tells that , the catche can be on the client only not on server or proxy server.

HttpCacheability.Public : Catching stored client & shared (proxy) server.
HttpCacheability.NoCache :Disable Catche

Sample Code :

    protected void Button1_Click(object sender, EventArgs e)
    {
         Response.Cache.SetExpires(System.DateTime.Now.AddDays(5);
         Response.Cache.VaryByHeaders["MyCache"]=true;
         Response.Cache.SetCacheability(HttpCacheability.Private);
    }

 Other than this , there are several ways to clear cache & control cache also . For example if we set 
<meta http-equiv="cache-control" content="no-catche" />

The catche will not work for this page , clear catching instantly for this page.
Previous , we learned about  @ OutputCache to set catche in HTML ,Now
@ OutputCache have some attribute


বাঙালির বেড়ানো সেরা চারটি ঠিকানা

  বাঙালি মানে ঘোড়া পাগল | দু একদিন ছুটি পেলো মানে বাঙালি চলল ঘুরতে | সে সমুদ্রই হোক , পাহাড়ি হোক বা নদী হোক। বাঙালির ...