开发者

Anonymous C# function with Windows Phone 7

开发者 https://www.devze.com 2023-03-22 16:19 出处:网络
How do I create an anonymous function type?I\'ve use开发者_如何学God \'void\' as a filler type:

How do I create an anonymous function type? I've use开发者_如何学God 'void' as a filler type:

private void afte(string filtr,void parse) {

    var request = (HttpWebRequest)WebRequest.Create(
        new Uri("xx.com"));
    request.BeginGetResponse(r => {
        var httpRequest = (HttpWebRequest)r.AsyncState;
        var httpResponse = (HttpWebResponse)httpRequest.EndGetResponse(r);

        using (var reader = new StreamReader(httpResponse.GetResponseStream())) {
            var response = reader.ReadToEnd();

            Deployment.Current.Dispatcher.BeginInvoke(new Action(() => {
                parse(response);
            }));
        }
    }, request);
}


Is parse a delegate that only accepts a string parameter (response) with a void return (or rather, without a return value)?

Use Action<string>:

private void afte(string filtr, Action<string> parse) {
0

精彩评论

暂无评论...
验证码 换一张
取 消