Jump to content
Xtreme .Net Talk

Recommended Posts

  • *Experts*
Posted

You don't need to worry about calling conventions in C#, since you can't export functions like that. However, you will need to learn how to use delegates.

 

You need to create a delegate called func, which accepts one byte parameter (to match your Func typedef):

public delegate void Func(byte b);

This is sort of a prototype for a function. You then need to place it in your function's parameter signature:

public myFunction(byte id, Func f) {
 // code here
}

You then have to create a function which matches the signature of the Func delegate, and pass that to your function. So:

public delegateFunction(byte b) { // matches Func's signature
 // do stuff with [b]b[/b] here
}

And when you call your first function:

myFunction(42, new Func(delegateFunction));

This is probably very confusing for you, but if you look up delegates in the MSDN, you'll find tons of information. :)

 

Good luck.

Posted
I will try it out. I was reading a bit about delegates. And it was written that it was preferable to make interfaces instead of delegates because of the type safety. What do you think about it ?
  • *Experts*
Posted
Interfaces are different. They are basically prototypes for entire classes. There's no real way that you could substitute and interface in this case.
  • 2 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...