We help IT Professionals succeed at work.

VAR to Method in c#

ITsolutionWizard
ITsolutionWizard asked
on
var responseStr = JsonConvert.DeserializeObject<Dictionary<string, string>>(message);
           

I want to pass VAR to other method like below but it does not look possible.
What type of datatype I can use for responseStr so I can pass the parameter into the method like Test below?

function void Test(responseStr)
{

}
Comment
Watch Question

Most Valuable Expert 2018
Distinguished Expert 2018
Commented:
Hi,

Your Deserialize method will return a Dictionary<string, string>, so type hint your method to that:

var responseStr = JsonConvert.DeserializeObject<Dictionary<string, string>>(message);
Test(responseStr);

function void Test(Dictionary<string, string> myDict)
{
}

Open in new window