C# Attributes Aren't Supposed to Inherit
Posted
by
Adam
on Stack Overflow
See other posts from Stack Overflow
or by Adam
Published on 2011-01-05T22:46:33Z
Indexed on
2011/01/05
22:53 UTC
Read the original article
Hit count: 156
Since attributes don't inherit in C# (at least I didn't think they did) - how does the following code still display the Hello popup when the MyTestMethod
test is run:
[TestClass]
public class BaseTestClass {
[TestInitialize]
public void Foo() {
System.Windows.Forms.MessageBox.Show("Hello");
}
}
[TestClass]
public class TestClass : BaseTestClass {
[TestMethod]
public void MyTestMethod() {
Assert.IsTrue(true);
}
}
© Stack Overflow or respective owner