How to pass a type as a parameter to a function?
For example:
void AddService(Type type);
And when I call the function send a type:
AddService(int)
I'm making a C# program to C++ program and this could send "data type" for eg inserting it into a Dictionary (in C + + would be a std :: map)
This is the function in C#:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
public class GEServiceContainer : GameServiceContainer
{
Dictionary<Type, object> services = new Dictionary<Type ,object>();
public GEServiceContainer()
{
}
public void AddService(Type Service, object Provider)
{
if (!services.ContainsKey(Service))
{
base.AddService(Service, Provider);
this.services.Add(Service, Provider);
}
}
public void RemoveService(Type Service)
{
if (services.ContainsKey(Service))
services.Remove(Service);
base.RemoveService(Service);
}
[...]
|
Topic archived. No new replies allowed.