T
Tony Johansson
Hello!
Class CharChecker has a field that is called TestChar that is of type event
CharEventHandler.
I know that if I change in method foo so I have
tester.TestChar +=new CharEventHandler(Testing);
it work so you don't have to mention that.
I have a reason for this testing so it has a value for me.
I wonder if it's possible to send this TestChar that is of type event
CharEventHandler as a parameter to another method
from Main in my example to another method in my case it's foo.
I can understand that what I'm doing seems rather strange but I just want to
know if it's possible.
I think you understand when you look at my code to see what I'm trying to
do.
using System;
public delegate void CharEventHandler(object source, CharEventArgs e);
public class CharEventArgs : EventArgs
{
public char CurrChar;
public CharEventArgs( char CurrChar )
{ this.CurrChar = CurrChar; }
}
public class CharChecker
{
private char curr_char;
public event CharEventHandler TestChar;
public char Curr_Char
{
get { return curr_char; }
set { if (TestChar != null) TestChar(this, new
CharEventArgs(value)); }
}
}
public class MyApp
{
private void foo(CharEventHandler arg, CharChecker tester)
{
tester.arg +=new CharEventHandler(Testing);
tester.Curr_Char = 'T';
}
public static void Main()
{
CharChecker tester = new CharChecker();
foo(tester.TestChar, tester );
}
static void Testing(object source, CharEventArgs e)
{ Console.WriteLine("Testing") }
}
//Tony
Class CharChecker has a field that is called TestChar that is of type event
CharEventHandler.
I know that if I change in method foo so I have
tester.TestChar +=new CharEventHandler(Testing);
it work so you don't have to mention that.
I have a reason for this testing so it has a value for me.
I wonder if it's possible to send this TestChar that is of type event
CharEventHandler as a parameter to another method
from Main in my example to another method in my case it's foo.
I can understand that what I'm doing seems rather strange but I just want to
know if it's possible.
I think you understand when you look at my code to see what I'm trying to
do.
using System;
public delegate void CharEventHandler(object source, CharEventArgs e);
public class CharEventArgs : EventArgs
{
public char CurrChar;
public CharEventArgs( char CurrChar )
{ this.CurrChar = CurrChar; }
}
public class CharChecker
{
private char curr_char;
public event CharEventHandler TestChar;
public char Curr_Char
{
get { return curr_char; }
set { if (TestChar != null) TestChar(this, new
CharEventArgs(value)); }
}
}
public class MyApp
{
private void foo(CharEventHandler arg, CharChecker tester)
{
tester.arg +=new CharEventHandler(Testing);
tester.Curr_Char = 'T';
}
public static void Main()
{
CharChecker tester = new CharChecker();
foo(tester.TestChar, tester );
}
static void Testing(object source, CharEventArgs e)
{ Console.WriteLine("Testing") }
}
//Tony