如何存储在C#中的函数指针 [英] How to store a function pointer in C#

查看:229
本文介绍了如何存储在C#中的函数指针的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

比方说,我想存储一组函数指针在名单≤(* FUNC)> ,再后来打电话给他们,甚至与参数.. 。就像如果我存储在字典≤(* FUNC),对象[] PARAMS> 我可以打电话与参数FUNC?我将如何做到这一点?

Let's say I want to store a group of function pointers in a List<(*func)>, and then later call them, perhaps even with parameters... Like if I stored in a Dict<(*func), object[] params> could I call the func with the parameters? How would I do this?

推荐答案

.NET使用委托而不是函数指针。您可以将委托实例像任何其他类型的对象,在字典中或以其他方式。

.NET uses delegates instead of function pointers. You can store a delegate instance like any other kind of object, in a dictionary or otherwise.

请参阅从MSDN上的C#编程指南代表

See Delegates from the C# Programming Guide on MSDN.

这篇关于如何存储在C#中的函数指针的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆