Friday, 5 September 2014

How to call a base class method even derived class object is created.

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

namespace InheritenceExample
{
class Program
{
static void Main(string[] args)
{
b obja = new b();
obja.Method1();
Console.ReadLine();
}
}


public class a
{
public virtual void Method1()
{
Console.WriteLine("base class method is called.");
}
}

public class b : a
{
public override void Method1()
{
base.Method1(); // calling base class method.
}
}

}
Result :  Base class method is called.

Interview Quations


Q1. Can we access the static webservice method by using Json ?

ANS. No

Q2. How to bind dropdownlist using  each function in jquery ?

ANS.    

                      <select id="ddlProducts"> </select> //html control
// jquery
            $("#ddlProducts").append($('<option>').text('select').attr('value', 0));
            $.each(data.d, function (i, item) {
            $('#ddlProducts').append($('<option>').text(item.ProductName).attr('value', item.ProductID));