C# function pointer?

前端 未结 5 1951
情话喂你
情话喂你 2020-12-25 12:40

I\'m having a problem with C#, I\'d like to get a pointer of a method in my code, but it seems impossible. I need the pointer of the method because I want to no-op it using

5条回答
  •  一生所求
    2020-12-25 12:47

    public string myFunction(string name)
    {
        return "Hello " + name;
    }
    
    public string functionPointerExample(Func myFunction)
    {
        return myFunction("Theron");
    }
    

    Func functionName.. use this to pass methods around. Makes no sense in this context but thats basically how you would use it

提交回复
热议问题