F
Frank Rizzo
I have an interface which has a bunch of methods defined that all the
inheriting classes will have to implement.
How can I force the inheriting classes to have a class attribute?
Something like this (except it does not compile)
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface)]
public class TestAttribute : Attribute
{
public TestAttribute (string name)
{
Console.Writeline(name);
}
}
[TestAttribute()]
public interface IReport
{
public void Execute();
}
[TestAttribute("Invoice Report")]
public class CoolReport
{
public void Execute()
{
Report.Run();
}
}
inheriting classes will have to implement.
How can I force the inheriting classes to have a class attribute?
Something like this (except it does not compile)
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface)]
public class TestAttribute : Attribute
{
public TestAttribute (string name)
{
Console.Writeline(name);
}
}
[TestAttribute()]
public interface IReport
{
public void Execute();
}
[TestAttribute("Invoice Report")]
public class CoolReport
{
public void Execute()
{
Report.Run();
}
}