문제


I look around the internet and find thing called Action that can execute void methods, if those voids are stores in variables.

void push(Action <string> action, string methodURL) {
if (methodURL != "123")
action(methodURL);
}

In this case, action is a method to execute and methodURL is it's future argument.

So, I expected to use this code something like that :

push(GetGroups(curTarget), GroupsXML);

GroupsXML is a string and GetGroups is a void with a string argument

and Visual Studio is showing me an error :

1.)Converting "void" to "action"

2.)Too much arguments

도움이 되었습니까?

해결책

Don't need to put stuff in brackets. C# is smart enough to work out and create the action for you.

push(GetGroups, GroupsXML);

Will dynamically convert it to an action

The code you have posted doesn't make so much sense though, you are only specifying one parameter into the action, yet you have two floating about curTarget and methodURL.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top