Friday, 26 October 2012

What is the difference between for and foreach loop?

foreach loop or statement is same as for loop or statement with a slight difference.In foreach loop , loop irterate through array and collections. Unlike for loop, foreach loop does not have test condition means it does not check any condition.
Example:

foreach Loop:

foreach( data_type data_variable in collection_name)
{
// your code
}

for loop:

for(data_type variable ;condition;update )
{
// your code
}

How to open computer without password?

Hi Friend's , Here I have explained some computer tips and tricks.
 If  you want to open your or someone else then it is too simple to open computer without password.
For this you have just do one simple step.
At login type administrator in user name  and click on login . This will open your computer without password.
If you don't believe just try it. If it will work just give a comment.

How to download Sql Server 2012.

Hi friend's , You can download sql server 2012 from the micrsoft site . If you want to crack it then You have    to do just one thing means just send a mail and i will send you cracker of server 2012. If you want to download sql server 2012 click here.

Tuesday, 23 October 2012

what are the core security feature of WCF address?


There are four core security feature of WCF
1.)Confidentiality: It is ensure that information doesn't go in wrong hand when it travels from sender to receiver.
2.)Integrity: It ensure that the receiver get the same  information that sender sends without any change in data.
3.)Authentication: It verifies who is the sender and who is receiver.
4.)Authorization: It verifies that the user is authorized or not for performing the action they are requesting from the application.


What are the main components of WCF.

Hi friend's, Here I have explained the main components of WCF.

There are three main components of WCF
1.)Service Class
2.)Hosting Environment
3.)End Point

what are the various ways of hosting of WCF?

Hi Friend's ,Here I have explained the various ways of hosting of WCF.

There are three ways to host WCF services:-
1.)Self Hosting:-Hosting the service on own machine or application domain.
2.)IIS Hosting:- Hosting the services on IIS server. Host the application on IIS server or provided by IIS server.
3.)WAS Hosting:- Hosting the applicarion on Windows Active Service (WAS) server.

Thursday, 18 October 2012

Factorial using recursion in c sharp

Hi Friend's ,Here I have Written code for Factorial using recursion in c#.

code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FactorialUsingRecursion
{
    class Program
    {
        static void Main(string[] args)
        {
           
            Console.WriteLine("Enter number.........");
            int n = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine(Factorial(n));
            Console.Read();
        }
        static long Factorial(int number)
        {
                        if (number < 1)
                return 1;
            else
                return number * Factorial(number - 1);
        }
    }
}

Factorial using for loop or without recursion in c sharp

Hi Friend's, Here I have written Factorial program without using recursion.

Code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Factorial
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Please enter the number.....");
            Console.WriteLine(Factorial());
            Console.Read();
        }
        static long Factorial()
        {
            int n =Convert.ToInt32( Console.ReadLine());
            long Finalnumber = 1;
            for (int i = 1; i <= n;i++ )
            {
                Finalnumber = Finalnumber * i;
            }
            return Finalnumber;
          
        }
    }
}

Count the number of vowels in string using c#.

Hi Friends, Here I have Written a simple program to count no of vowels in string in c sharp.

Code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FindVowel
{
    class Program
    {
        static void Main(string[] args)
        {
            int my_count = 0;
            Console.WriteLine("Enter String........");
            string myString= Console.ReadLine();
            foreach(char ch_vowel in myString)
            {
                switch (ch_vowel)
                {
                    case 'a':
                    case 'A':
                        my_count++;
                        break;
                    case 'e':
                    case 'E':
                        my_count++;
                        break;
                    case 'i':
                    case 'I':
                        my_count++;
                        break;
                    case 'o':
                    case 'O':
                        my_count++;
                        break;
                    case 'u':
                    case 'U':
                        my_count++;
                        break;
                }
            }
            Console.WriteLine("Number of vowels are :{0}",my_count);
            Console.Read();
        }
    }
}

Fibbonacci series program using recursion in C#.

Hi Friends, Here I have Written Fibbonacci series code in C sharp.

Code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Fibbonacies
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int i = 0; i <= 10;i++ )
                Console.WriteLine(Fibbonanci(i));
            Console.Read();
        }
        static int Fibbonanci(int x)
        {
            if (x < 1)
                return 1;
            return Fibbonanci(x - 1) + Fibbonanci(x-2);
        }
    }
}

Sunday, 14 October 2012

What is url routing?


Hi Friend’s ,Here I have explained a new feature in asp.net 4.0.

Introduction:

URL routing is one of the new thing in Asp.net4.0.You can just said that you can reduce the url length and make it user friendly i.e you can arrange the url in your own way. Developers  build the url dynamism , readability and flexibility to the user. You have seen lot of url’s that are very lengthy and ugly. User’s avoid to cut and paste or to remember it. It is very tuff task for user ‘s that means it is not user friendly.
You have seen url’s like
We know how ugly they are. To avoid such type of url name ,Asp.net 4.0 brings a new concept called url routing.
With the use of url routing  ,you can manage your url in proper way so that it is easy for cut and paste or user can remember the url.
After Using of url routing the url will become as below
Procedure for url Routing:
First you create a simple web project in which at least two web form.
Add  Global.asax file in this project.
Open Global.asax file  and write the code in following section:-
<%@ Application Language="C#" %>

<script runat="server">

    void Application_Start(object sender, EventArgs e)
    {
        // Code that runs on application startup
       
        System.Web.Routing.RouteTable.Routes.MapPageRoute("",
    "Home",
    "~/linq/Default.aspx"); // in this code ~/linq/Default.aspx is the original name(url) and Home is the new name (It is written by myself or you can give the name  whatever you want )

    }
  
    void Application_End(object sender, EventArgs e)
    {
        //  Code that runs on application shutdown

    }
       
    void Application_Error(object sender, EventArgs e)
    {
        // Code that runs when an unhandled error occurs

    }

    void Session_Start(object sender, EventArgs e)
    {
        // Code that runs when a new session is started

    }

    void Session_End(object sender, EventArgs e)
    {
        // Code that runs when a session ends.
        // Note: The Session_End event is raised only when the sessionstate mode
        // is set to InProc in the Web.config file. If session mode is set to StateServer
        // or SQLServer, the event is not raised.

    }
      
</script>

 This is the simple url routing .
If you want to write the code on button event or any other event. For this you have to write the new name in Respose.Redirect(). Method.
For Example:
protected void Button1_Click(object sender, EventArgs e)
    {
        Response.Redirect("Home");
    }

Hope this will help u. If any query regarding this please Conatact me at sushilct86@gmail.com.
If you like this post do not forget to cooment.

Friday, 12 October 2012

How Linq is more benifacial than stored procedure?

Hi Friends , Here I have explained how linq is more benifacial than stored procedure.

There are three basic points that explain how linq is benifacial than stored procedure.
1.)  Debugging: It is very hard to debugg stored procedure but as we know linq is the part of .NET , so we can use debugger to debugg the linq query.
2.)Development: at the time of deployment , we use additional script for stored procedure but for Linq query it is complied into a single DLL hence deployment is easy.
3.)Type Safety: Linq is type safe , so queries error are type checked at complie time but in case of stored procedure error are checked at run time.

What is Linq in Asp.Net?

Hi Friends , Here I have explained about new topic .i.e Linq.

 Intoduction: 

Linq stands for Langauge Integrated Query.It the new feature of Asp.Net Starting in .NET 3.5. Linq is collection of  standard query operator that provides the query facilities in .NET framework langauge like c#,VB.NET.
:-It use a single syntax  for querying multiple data source such as sql server, MSAcesses, Oracle,XML data.
:- It is type safe and strongly type.
:- linq is that is programming langauge synatx that is used for querying data. 

What is web.config file in Asp.Net?


Hi friends , Here I have explained what is web.config file in Asp.Net.

Introduction:

Web.config is the central part of the  Asp.Net application. It is used to store the information to be accessed by web page. This  information  could be connectionString stored at at Centralized part so that it can be accessed in data driven page. If the connection string change its  just a matter of changing it at one place.
In the sample  we shall red the information from web.config using Asp.Net .
Below  the code have given as:-
Web.config:
<?xml version=”1.0” encoding=”utf-8”?>
<configuration>
<connectionString>
<add key=”connectionName”  connectionString=”Data Source=DataServerName; Initial Caalog= yourDatabaseName; Integrated Security=True”
</connectionString>
</configuration>
In Asp.Net
String  connStr=ConfigurtionManager.ConnectionString[“connectionName”].ConnectionString;
Sqlconnection  conSql=new SqlConnection(connStr);
consql.Open();
………write your code
conSql.Close();

Thursday, 11 October 2012

Differences between Abstract class and Interface.

Hi friends, Here I have explained what are the basic differences between Abstract class and Interface. This is the general question always asked in interviews.

There are  5 main differences between abstract class and Interface:-
1.)A class can implement many number of interfaces but a sub class can at most use only one abstract class.
2.) An abstract class can have non-abstract method(Concrete method) while in case of interface all the methods has to abstract.
3.)An abstract class can declare or use any variables while an interface is not allowed to do so.
          So the following code cann't be compiled:-
     interface TestInterface
{
int x=4;
int k=3;
void getMethod();
string getName();
}

abstract class TestAbstract
{
int i=4;
int x=3;
public abstract void getClassName();
}

It will generate a compile time error as:-
Error1 Interface cannot contain fields.

4.)An abstract class have constructor declaration while an interface can not do so.


  interface TestInterface
{
//constructor declaration
public TestInterface()
{

}
void getMethod();
string getName();
}

abstract class TestAbstract
{
public TestAbstract()
{

}
int i=4;
int x=3;
public abstract void getClassName();
}

Above code generate a compile time error as:-
Error1 Interface does not contain constructors.

5.) An abstract class is allowed to have all modifier for all of its member declaration while in interface we cannot declare any access modifier(including public) as all the member of interface are implicitly public.

Correct code:
public Interface TestInterface
{
void getMethod();
string getName();
}

Inccorect Code:

 Interface TestInterface
{
public void getMethod();
public string getName();
}

Monday, 8 October 2012

what is proxy in WCF? How to create proxy in WCF.

Hi Friends, Here i have explained what is proxy in WCF and How we create proxy in WCF.

Introduction:

The proxy is a CLR class that exposes a single CLR interface represnting the  service contract. The proxy provides the same operations as service contract. It also has additional method for managing the proxy life cycle and the connection to the service.The proxy completely encapsulate every aspect of the service:its location,  its implementation technology and runtime plateform , and the communication transport.

The proxy can be generated using Visual Studio by right clicking reference and clicking on add Service Refernce. This brings up the Add Service Refernce dialog box,Where you need to supply the base address of the service(or a base address and a MEX URI) and the namespace to contain the proxy.

Proxy can also be generated by using svcUtil.exe command line utility.We need to provide svcUtil with the HTTP-GET address or the metadata exchange endpoint address and ,optionally with a proxy filename. The default proxy filename is output.cs but you can also use the /out switch to indiacte a different name.


Tuesday, 2 October 2012

what is endpoint in WCF?



Hi friends,here i have explained a tiny question that was asked to my friend in interview.

Every service must have Address that defines where the service resides, Contract that defines what the service does and a Binding that defines how to communicate with the service. In WCF the relationship between Address, Contract and Binding is called Endpoint.

The Endpoint is the fusion of Address , Contract and Binding.

What is queryString in asp.net.


Hi friend, here i have explained about QueryString.
Introduction:
QueryString  is used to pass the variables content  between your HTML  page or aspx webform  context in asp.net. For Example if you collect the information like  user_name and id and you want to pass these value to another page.For this you can use QueryString.
Exmple :
 you want to show like this
http:/www.yourdomainname.com/default.aspx?username=Rahul&id=10023
for this you can write the code given below:

private void btnGO_Click(object sender, System.EventArgs e)
{
Response.Redirect(“Default.aspx?username=”+txt_username.Text+”&id=”+txt_id.Text);
}     

If you want  to retrieve these value  to another page write the code given below

private void Page_Load(object sender,System.EventArgs e)
{
txt_name.Text=Request.QueryString["username"];
Txt_id.Text=Request.QueryString["id"];
}

Advantage:

It is easy to write.

Limitations:
1.)It have a max length.If you have to send a lot information this approach doesn’t work.
2.)It is visible in your address part of your browser so you cant use it with the sensitive information.
3.)It can not be used to send & and space.

Wednesday, 26 September 2012

What are differences between system.stringbuilder and system.string?


1.)system.string is immutable but system.stringBuilder is mutable.
Immutable means once we created we cannot modified.    Suppose we want give new value to old value simply it discarded the old value and it will create new instance in memory to hold the new value.
2.)append keyword is used in string builder but not in system.string.

What is difference between Array list and hash table?


1.)Hash table store data as a name ,value pair while in array only value is store.
2.)To access value from Hash table ,you hve to pass name while in array ,to access value, you have to pass index number.
3.)You can store different data type in Hash table like int, string but in array you can store only similar type of data.