I am not sure for what you'll need this but this should work for you:
private void test()
{
IList<object> list = new List<object>();
list.Add("mystring");
Func<string, string> anyFunction = AnyFunction;
list.Add(anyFunction);
Action voidFunction = AnyVoidFunction;
list.Add(voidFunction);
foreach (var item in list)
{
if (item is string)
{
Debug.WriteLine(item);
}
if (item is Func<string,string>)
{
var result = (item as Func<string, string>)("Call it");
Debug.WriteLine("Function result is: "+result);
}
if(item is Action)
{
//Call method
(item as Action)();
}
}
//as it is a list you can of course index it
var indexedItem = list[0];
}
private string AnyFunction(string inputString)
{
return "Anything "+ inputString;
}
private void AnyVoidFunction()
{
Debug.WriteLine("AnyVoidFunction called!");
}
The variable 'list' will hold the string "mystring", the function "AnyFunction" and the method "AnyVoidFunction".
Then the list is iterated. The output will be:
mystring
Function result is: Anything Call it
AnyVoidFunction called!
This will work with all the arrays, lists, dictionaries, stacks, queues and so on in C#.
btw.: As the focus of the question is not really game releated but more of a programming question: https://stackoverflow.com/ will be better to ask.