Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class BaseClass
- {
- public virtual IEnumerable<string> Names
- {
- get
- {
- yield return "Taro";
- }
- }
- }
- public class DerivedClass : BaseClass
- {
- public override IEnumerable<string> Names
- {
- get
- {
- // 他にカッコイイ書き方ないの?
- foreach(var name in this.BaseNames) yield return name;
- yield return "Jiro";
- yield return "Saburo";
- }
- }
- // HACK: コンパイラ警告 CS1911 を解決 (http://msdn.microsoft.com/library/ms228459.aspx)
- private IEnumerable<string> BaseNames
- {
- get { return base.Names; }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement