Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Foo<T>
- {
- protected class Private2 : Private1<Foo<T>>
- { }
- protected class Private1<T2> where T2 : Foo<T>
- {
- public sealed class Nested
- {
- public void Test(T2 foo)
- {
- foo.Method2(this); //Nope!
- var nes = (Private2.Nested)this; //Nope!
- }
- }
- }
- public void Method1()
- {
- var nested = new Private2.Nested();
- nested.Test(this);
- }
- private void Method2(Private2.Nested nested)
- {
- // something code...
- }
- }
- public class Bar<GoodName, OtherName, Readability, NopeMr, DontThinkSo, Suffering, Dispair>
- {
- //If only this was real...
- using BarT = Bar<GoodName, OtherName, Readability, NopeMr, DontThinkSo, Suffering, Dispair>;
- public void Method1(BarT bar) { ... } //so good!!
- //goodbye readability... see you never...
- public void Method2(Bar<GoodName, OtherName, Readability, NopeMr, DontThinkSo, Suffering, Dispair> whatIsThisVariable) { ... }
- }
- public class Base {
- public static int Value;
- public class Nested { }
- }
- public class Derived:Base { }
- public static void Test() {
- Derived.Value=10;
- Console.WriteLine(Base.Value);
- Base.Value=20;
- Console.WriteLine(Derived.Value);
- Base.Nested bn=new Derived.Nested();
- Derived.Nested dn=new Base.Nested();
- Console.WriteLine(typeof(Base.Nested).FullName);
- Console.WriteLine(typeof(Derived.Nested).FullName);
- Console.WriteLine(typeof(Base.Nested)==typeof(Derived.Nested));
- }
- public class Foo<T>
- {
- private class Private2 : Private1
- { }
- private class Private1
- {
- public sealed class Nested
- {
- public void Test( Foo<T> foo )
- {
- foo.Method2( this ); //Yup
- var nes = (Private2.Nested)this; //Yup
- }
- }
- }
- public void Method1()
- {
- var nested = new Private2.Nested();
- nested.Test( this );
- }
- private void Method2( Private2.Nested nested )
- {
- // something code...
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement