Using Generic Class

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;
}
}
 
J

Jon Skeet [C# MVP]

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top