在 C# 中是否可以将类函数(非静态)作为函数中的参数传递?
出于某种原因,我在函数下载中遇到编译错误,因为我将“类/实例”函数作为参数传递。
例如:
public class MyPlane {
Texture texture;
virtual public void OnDownloadPlaneCallBack(WWW www) {
// perform custom actions when/if file downloads correctly
texture = www.texture;
}
virtual public void download() {
Downloader.download("www.blah.com", OnDownloadPlaneCallBack); // this gives a compile error?
}
}
public class Downloader {
public static IEnumerator download(string url, Delegate callback) {
WWW www = new WWW(url);
while(!www.isDone)
yield return www;
if (www.isDone) {
callback.DynamicInvoke(www);
}
}
}