Convert object do dictionary  
Author Message
Rodrigo Ferreira





PostPosted: Visual C# General, Convert object do dictionary Top

i all

I have this method in my app:

public bool MTProcess(string PathOut, string PathControl, params object[] arr)

In arr parameter i received a dicitionary and i want do cast this arr to a private dictionary inside this method!

Any help!




Visual C#3  
 
 
csharprocks.com





PostPosted: Visual C# General, Convert object do dictionary Top

Change the array to a dictionary object or change the dictionary object to array before passing. Once the cast is in place, the parameter will no longer be an array.

Craig Maslowski



 
 
James Curran





PostPosted: Visual C# General, Convert object do dictionary Top

Assuming you mean you have something like this:

bool b = MTProcess("pathout", "pathcontrol", new Dictionary());

Then you'd want:

public bool MTProcess(string PathOut, string PathControl, params object[] arr)
{
Dictionary dict = (Dictionary) arr[0];



 
 
Rodrigo Ferreira





PostPosted: Visual C# General, Convert object do dictionary Top

Ok it works fine, but i change something...

Dictionary<int, string> dict = (Dictionary<int, string>)arr[0];