Using Generic Class

  • Thread starter Thread starter Mel
  • Start date Start date
M

Mel

I have a few of this same basic class all the same except the name. Is it
possible to use generic to improve this?

Thanks
Mel


public class BaseFactors
{
private string name;
private double factors;

public double Factors
{
get { return factors; }
set { factors = value; }
}

public string Name
{
get { return name; }
set { name = value; }
}

public BaseFactors(string name, double factors)
{
this.name = name;
this.factors = factors;
}
}
 
Mel said:
I have a few of this same basic class all the same except the name. Is it
possible to use generic to improve this?

I'm not sure you need generics particularly. Can't you derive your
other classes from BaseFactors, possibly making BaseFactors abstract
and changing the constructor access from public to protected?
 
Back
Top