when we go for webservices in .net webapplications? example plz?
2.what is mean by delegate and asynchronous delegate in .net
3.static method with example?plz

I don't mean to give a useless answer but a simple Google search of all the above questions gives immediate and rich answers...

when we go for webservices in .net webapplications? example plz?
2.what is mean by delegate and asynchronous delegate in .net
3.static method with example?plz

A web service is used like any other applications that provide services like dll for example it could hold a set of web methods those serves to make calculs or so. you can add them into your application you just go to the solution explorer right click on your project then click add web reference then follow the instructions to add your webservice
To instanciate it you just type it name it will appear in the intellisense for example if the web service is on the localhost server
LocalHost.ServiceName x = new LocalHost.ServiceName();

a delegate is a sort of method pointer, you can use it when you have more than one method but you want to chose when use each one

try this code for example

using System;

public delegate string DelegateDescription();

public class Person
{
  private string name;
  private int age;

  public Person(string name, int age)
  {
    this.name = name;
    this.age = age;
  }

  public string NameAndAge()
  {
    return(name + " is " + age + " years old");
  }

}

public class Employee
{
  private string name;
  private int number;
  public Employee(string name, int number)
  {
    this.name = name;
    this.number = number;
  }

  public string MakeAndNumber()
  {
    return(name + " is " + number + " mph");
  }
}

class MainClass
{
  public static void Main()
  {
    Person myPerson = new Person("Price", 32);
    DelegateDescription myDelegateDescription = new DelegateDescription(myPerson.NameAndAge);

    string personDescription = myDelegateDescription();
    Console.WriteLine("personDescription = " + personDescription);

    Employee myEmployee = new Employee("M", 140);

    myDelegateDescription = new DelegateDescription(myEmployee.MakeAndNumber);

    string d = myDelegateDescription();
    Console.WriteLine(d);
  }
}

Asynchrone delegate are used when asunchrone calls are needed

Try this code

using System;


public class AsynchronousCallsASimpleExample
{
    public static void Main()
    {
        AsyncCaller ac = new AsyncCaller();
        ac.CallWriteLine("Hello");
    }
}

public class AsyncCaller
{
    // Declare a delegate that will match Console.WriteLine("string");
    delegate void FuncToCall(string s);

    public void CallWriteLine(string s)
    {
        // delegate points to function to call
        // start the async call
        // wait for completion
        FuncToCall func = new FuncToCall(Console.WriteLine);
        IAsyncResult iar = func.BeginInvoke(s, null, null);
        func.EndInvoke(iar);
    }
}

Edited 3 Years Ago by pritaeas: Fixed formatting

This article has been dead for over six months. Start a new discussion instead.