Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualNightCreature83

Posted 27 November 2012 - 06:34 AM

Yeah basically you do this
delegate void ButtonDelegate(); //This can return a value and take parameters and is only the definition of how the function should look

class Button
{
public Button(ButtonDelegate delegate)
{
	 m_delegate = delegate;
}

public onButtonClick()
{
	 m_delegate();
}

private ButtonDelegate m_delegate;
}

static class Wrapper
{
public static void printHelloWorld()
{
	 Console.WriteLn("Hello World! From delegate call"):
}
}

Button button = new Button(Wrapper.printHelloWorld);
button.onButtonClick();
}


See http://msdn.microsoft.com/en-us/library/900fyy8e%28v=vs.80%29.aspx for more information on delegates. A delegate is effictivly a function pointer and it is a way for you to give a function to something else and call that particular function from that something else, this is how callbacks in C/C++ are usually implemented.

#4NightCreature83

Posted 27 November 2012 - 06:34 AM

Yeah basically you do this
delegate void ButtonDelegate(); //This can return a value and take parameters and is only the definition of how the function should look

class Button
{
public Button(ButtonDelegate delegate)
{
	 m_delegate = delegate;
}

public onButtonClick()
{
	 m_delegate();
}

private ButtonDelegate m_delegate;
}

static class Wrapper
{
public static void printHelloWorld()
{
	 Console.WriteLn("Hello World! From delegate call"):
}
}

Button button = new Button(Wrapper.printHelloWorld);
button.onButtonClick();
}


See http://msdn.microsoft.com/en-us/library/900fyy8e%28v=vs.80%29.aspx for more information on delegates. A delegate is effictivly a function pointer and it is a way for you to give a function to something else and call that particular function from that something else, this is how callbacks in C/C++ are usually implemented.

#3NightCreature83

Posted 27 November 2012 - 06:34 AM

Yeah basically you do this
delegate void ButtonDelegate(); //This can return a value and take parameters and is only the definition of how the function should look

class Button
{
public Button(ButtonDelegate delegate)
{
	 m_delegate = delegate;
}

public onButtonClick()
{
	 m_delegate();
}

private ButtonDelegate m_delegate;
}

static class Wrapper
{
public static void printHelloWorld()
{
	 Console.WriteLn("Hello World! From delegate call"):
}

Button button = new Button(Wrapper.printHelloWorld);
button.onButtonClick();
}


See http://msdn.microsoft.com/en-us/library/900fyy8e%28v=vs.80%29.aspx for more information on delegates. A delegate is effictivly a function pointer and it is a way for you to give a function to something else and call that particular function from that something else, this is how callbacks in C/C++ are usually implemented.

#2NightCreature83

Posted 27 November 2012 - 06:34 AM

Yeah basically you do this
delegate void ButtonDelegate(); //This can return a value and take parameters and is only the definition of how the function should look

class Button
{
public Button(ButtonDelegate delegate)
{
	 m_delegate = delegate;
}

public onButtonClick()
{
	 m_delegate();
}

private ButtonDelegate m_delegate;
}

static class Wrapper
{
public static void printHelloWorld()
{
	 Console.WriteLn("Hello World! From delegate call"):
}

Button button = new Button(Wrapper.printHelloWorld);
button.onButtonClick();
}


See http://msdn.microsoft.com/en-us/library/900fyy8e%28v=vs.80%29.aspx for more information on delegates. A delegate is effictivly a function pointer and it is a way for you to give a function to something else and call that particular function from that something else, this is how callbacks in C/C++ are usually implemented.

#1NightCreature83

Posted 27 November 2012 - 06:31 AM

Yeah basically you do this
delegate void ButtonDelegate(); //This can return a value and take parameters and is only the definition of how the function should look

class Button
{
public Button(ButtonDelegate delegate)
{
	 m_delegate = delegate;
}

public onButtonClick()
{
	 m_delegate();
}

private ButtonDelegate m_delegate;
}

static class Wrapper
{
public static void printHelloWorld()
{
	 Console.WriteLn("Hello World! From delegate call"):
}

Button button = new Button(Wrapper.printHelloWorld);
button.onButtonClick();
}


See http://msdn.microsoft.com/en-us/library/900fyy8e%28v=vs.80%29.aspx for more information on delegates.

PARTNERS