08/03/26 12:56:02 TCtOpY+/
static class Hogeable {
public interface IHogeable { Hogeable.HogeableObject HogeableObject { get; } }
public class HogeableObject { public int Value { get; set; } }
public static void Hoge(this IHogeable hoge) {
hoge.HogeableObject.Value += 1;
Console.WriteLine(hoge.HogeableObject.Value);
}
}
class MyClass : MyBaseClass, Hogeable.IHogeable {
private Hogeable.HogeableObject hogeableObject = new Hogeable.HogeableObject();
Hogeable.HogeableObject Hogeable.IHogeable.HogeableObject { get { return hogeableObject; } }
}
//MyClass obj = new MyClass(); for (i=0;i<10;i++)obj.Hoge();
こうすればインスタンスフィールドも持てるんじゃね