Ross Buggins

Partner at Shore Tech Systems LLP a Norwich based IT consultancy

Forwarding Events in C#

by Ross Buggins26. May 2011 08:12
If you ever want to forward events between a class and an instance of a class wihin that class, then here is the best way to do it.   public class Test { public Test() { var a = new A(); a.MyEvent += new EventHandler<EventArgs>(a_MyEvent); } void a_MyEvent(object sender, EventArgs e) { //event fired! } } /// <summary> /// my class /// </summary> public class A { private B MyB = new B(); public event EventHandler<... [More]

Tags:

Custom Scopes - great way to manage objects

by Ross Buggins16. May 2011 16:37
[No text]

Tags:

Using Flag Attribute for enums with example

by Ross Buggins16. May 2011 16:35
Example of using Flag Attribute on enums:   using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication4 { [FlagsAttribute] enum Survival : short { GiveWater = 1, GiveFood = 2, GiveSleep = 4 }; class Program { static void Main(string[] args) { for (int i = 1; i < 8; i++) Console.WriteLine(((Survival)i).ToString()); Console.WriteLine("*"); Console.WriteLine("*"); Test(Survival.GiveWater); ... [More]

Tags:

Month List

A little about us