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) {
精彩评论