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 7953935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:16:28+00:00 2026-06-04T03:16:28+00:00

Today in an interview (junior web developer) the interviewer asked me this question: How

  • 0

Today in an interview (junior web developer) the interviewer asked me this question:

How you can execute a Method when you have its name as a string ( in
javascript and in C# )

I can not answer 🙁

Now when I searched I found this question How to execute a JavaScript function when I have its name as a string

but how do this in c# ??

  • 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-04T03:16:29+00:00Added an answer on June 4, 2026 at 3:16 am

    If you just have name of the method than you can make use of .net Relfection only to run that method..

    Check : MethodBase.Invoke Method (Object, Object[])

    or

    Example :

    class Class1
       {
        public int AddNumb(int numb1, int numb2)
        {
          int ans = numb1 + numb2;
          return ans;
        }
    
      [STAThread]
      static void Main(string[] args)
      {
         Type type1 = typeof(Class1); 
         //Create an instance of the type
         object obj = Activator.CreateInstance(type1);
         object[] mParam = new object[] {5, 10};
         //invoke AddMethod, passing in two parameters
         int res = (int)type1.InvokeMember("AddNumb", BindingFlags.InvokeMethod,
                                            null, obj, mParam);
         Console.Write("Result: {0} \n", res);
       }
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I went to an interview today and was asked this question: Suppose you have
I was asked this question in an interview today. I have tried a solution
I was asked this in my interview today, I applied for a graduate developer
I had an interview today and the person asked me this question: How do
Got this question in an interview today, and its optimized solution stopped me cold
I had an interview today and was asked this question! code the MS Paint
Today, an interviewer asked me this question. My immediate response was that we could
I was asked this in an interview today and I just can't figure it
I was asked this question in an interview today. When we create a thread
Got asked this interesting interview question today. Explain in detail the process by which

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.