Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 296
  • Last Modified:

call a method from a variable name

Is it possible to call a method using a variable name?

varname="Function1"
varname()

varname = "Function2"
varname()
0
Delta7428
Asked:
Delta7428
1 Solution
 
crazymanCommented:
No it isnt, however using reflection you can.

eg

this.GetType().GetMethod("AMethodName").Invoke(this);

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now