// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; namespace E { public class Person { public string Name { get; set; } } public class Foo { private Person p; public Foo(Person p) { this.p = p; } public void A() { Console.WriteLine(p.Name + " called Foo.A"); Console.WriteLine("A"); } public void B() { Console.WriteLine(p.Name + " called Foo.B"); Console.WriteLine("B"); } } public class Bar { private Person p; public Bar(Person p) { this.p = p; } public void C() { Console.WriteLine(p.Name + " called Bar.C"); Console.WriteLine("C"); } public void D() { Console.WriteLine(p.Name + " called Bar.D"); Console.WriteLine("D"); } } public class ApplicationLogic { public void DoSomethings() { Person p = new Person { Name="Arne" }; Foo foo = new Foo(p); foo.A(); foo.B(); Bar bar = new Bar(p); bar.C(); bar.D(); } } public class Program { public static void Main(string[] args) { ApplicationLogic app = new ApplicationLogic(); app.DoSomethings(); } } }