by Ross Buggins26. May 2011 08:12If 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]bab9b836-5751-4106-9ed5-8bb46d99b6ca|0|.0|96d5b379-7e1d-4dac-a6ba-1e50db561b04
Tags:
by Ross Buggins16. May 2011 16:37[No text]
cdcddfae-48e0-46b7-8bd7-605bc4dc114b|0|.0|96d5b379-7e1d-4dac-a6ba-1e50db561b04
Tags:
by Ross Buggins16. May 2011 16:35Example 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]d53bcded-a920-4abe-8f32-ea9d50302cf3|0|.0|96d5b379-7e1d-4dac-a6ba-1e50db561b04
Tags: