Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8271769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:55:49+00:00 2026-06-08T06:55:49+00:00

In C# is it possible to pass a class function(not static) as a parameter

  • 0

In C# is it possible to pass a class function(not static) as a parameter in a function?

For some reason I get a compile error inside the function download because I am passing a ‘class/instance’ function as the parameter.

For example:

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);
         }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T06:55:51+00:00Added an answer on June 8, 2026 at 6:55 am

    Of course you can construct delegates from instance methods: that is a very powerful feature. The problem that you are seeing has to do with a specific syntax of creating delegates – by using method groups.

    You get a compile error because method groups (that’s the official name for constructing delegates from “naked” method names) cannot be passed as parameters of “untyped” Delegates.

    If you change the signature of your download method to accept Action<WWW>, your code will compile correctly. You could also cast your method group explicitly, like this:

    Downloader.download("www.blah.com", (Action<WWW>)OnDownloadPlaneCallBack);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to pass some parameters to constructor of a class inside a
Possible Duplicate: pass parameter in g:remoteLink as result of javascript function I am trying
Possible Duplicate: pass by reference not working I was going through some of the
Is it possible to pass TargetActivity.class to another activity and do something like: //
I have been lead to believe that it is possible to pass a class
Is it possible to pass *args to string.format? I have the following function: @classmethod
I've found myself that I tend not to have private class functions. If possible,
I'm wondering is it possible somehow? sample code class CustomFilter { ... function FilterData($data,
is it possible to pass a property eg. Person.Firstname by reference to a function
I have a static function in a class with two overloads. Both the overloads

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.