What is Error in this

Posted by Saranpselvam under C# on 10/17/2014 | Points: 10 | Views : 1206 | Status : [Member] | Replies : 1
Hi

I am trying to inherit Interface in inner class . Pls help me what is error in this

public class Vehicle
{

internal class CAR : IVehicle
{
public int GetPrice()
{

return 300000;
}
}

class BUS : IVehicle
{
public int GetPrice()
{

return 600000;
}
}
class VAN : IVehicle
{
public int GetPrice()
{

return 5000000;
}
}

public interface ICar
{
int GetCarPrice();
}

public interface IBus
{
int GetBusPrice();
}

public interface IVan
{
int GetVanPrice();
}

public interface IVehicle : ICar, IBus, IVan
{
int GetPrice();
}

class DiscountPrice
{
IVehicle CalculateDiscount(String ClassName)
{
IVehicle objIreport = null;
Type objectType = Type.GetType(ClassName);

if (objectType.IsClass)
{
objIreport = (IVehicle)Activator.CreateInstance(objectType);
}

return objIreport;
}
}
}





Responses

Posted by: kgovindarao523-21772 on: 10/24/2014 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Hi,

A member declared in an interface should have to implement in derived class. right?
In your scenario, even you derived interfaces in another interface, compiler checks for inheritance hierarchy.
so you must have to implement those members/methods in derived class which are CAR,BUS,VAN

Thank you,
Govind

Saranpselvam, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response