Hi,

I am very week in design and program to interface. I have a task to design few classes. I have some simple interfaces
like below. Sample interfaces.

 public interface IParameterValue
    {
        string ParameterName { get; set; }
        string ParameterValu { get; set; }
    }

the above interface is a kind of common interface.

The below interfaces should actually implement the above interface.

Area Parameter interface:

public interface IAreaParameter
    {
        string AreaId { get; set; }
    }

    public class AreaParameter : IAreaParameter
    {
       public string AreaId { get; set; }
    } public interface IParameterValue
    {
        string ParameterName { get; set; }
        string ParameterValu { get; set; }
    }

Plot paramtere interface:

 public interface IPlotParameter
    {
        string AreaId { get; set; }
        string PartId { get; set; }
    }

    public class PlotParameter : IPlotParameter
    {
        public string AreaId { get; set; }
        public string PartId { get; set; }
    }

Now the common interface IParameterValue has ParameterName and ParameterValu.
There will be one more incoming value scope. depending on the scope
the paramterValu will be applied Area wise or Plot wise.

Now, I think we have to implement IParameterValue interface to IAreaParameter and IPlotParamter.
My question is, how to implement in code and if we implement how to access all this paramters
from other class and assign a value to them.

Simple question i think but did'n work with interfaces more so...

Thanks.

Let me clarify my question in other way.

I know how to implement an interface.
My question is design related and also if we implement the interface like below, how to
access it and assign values to all the properties and also read them.

Say, Interface is implemented like this:

  public interface IParameterValue
    {
        string ParameterName { get; set; }
        string ParameterValu { get; set; }
    }


 public interface IAreaParameter
    {
        string AreaId { get; set; }
    }

 public interface IPlotParameter
    {
        string AreaId { get; set; }
        string PartId { get; set; }
    }

Implementaion:

 public class AreaParameter : IAreaParameter, IParameterValue
    {
       public string AreaId { get; set; }
       public string ParameterName { get; set; }
       public string ParameterValu { get; set; }
    }

  public class PlotParameter : IPlotParameter, IParameterValue
    {
        public string AreaId { get; set; }
        public string PartId { get; set; }

        public string ParameterName { get; set; }
        public string ParameterValu { get; set; }

    }

Do I need to implement IParameterValue interface in a saparate class ParameterValue??

How to assign or access a value to these fields from other class say a class "USER"?
Actually, i don'nt know how to code this for assigning and retriving values ?

Thanks.

I'm not entirely sure what you're asking, sorry. Is it possible for you to put a code example of what you'd like to do? The code doesn't have to work, it's just to explain exactly what you want.

You have everything you need already. You just need to create an instance your class.

        PlotParameter pm = new PlotParameter();
        pm.AreaId = "id-1";
        pm.ParameterName = "fred";
        pm.ParameterValu = "wilma";
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.