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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:47:39+00:00 2026-05-13T20:47:39+00:00

I have a class in .NET (C#): public class MyHelper { public object exec(

  • 0

I have a class in .NET (C#):

public class MyHelper {
    public object exec( string script, params object[] arguments ) {
        // execute script with passed arguments in some external enviroment
    }
}

I’m using IronPython runtime in my code to run python scripts, which should in some cases call the “exec” method. I would like serve the comfortable way to call the “exec” method. Something like:

helper.exec( "someExternalFunction( {0}, {1}, {3} )", var01, var02, var03 )

But I don’t know how to declare the “exec” method in C# to achieve this. In python I can use a “*args” argument:

def exec( script, *args ):
    ... do something ...

I don’t want have separate Python method “exec” from “MyHelper” class, because the “MyHelper” class provides complex functionality “in one place”.

How should I write the “exec” method declaration in C# to achieve that? Or what other solution should I use?

Thanks

  • 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-05-13T20:47:39+00:00Added an answer on May 13, 2026 at 8:47 pm

    The problem here is that “exec” is a keyword in Python so you can’t use that as your function name. You could use “exec_” or execute or something like that instead. Alternately you could write:

    getattr(helper, ‘exec’)(…)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have a .NET class like so: public class Person { public string
I have the following in a program (written in VB.NET): Imports Microsoft.Office.Interop.Excel Public Class
I have inherited a class in vb.net and when I create the object, I
I have created a class library in VB .NET. Some code in the library
I have a .NET class library that I wrote in C++. public ref class
I have a 32 bit .NET class library having a simple public class and
I have a .NET class library containing a class with a method that performs
I have a class 'Database' that works as a wrapper for ADO.net. For instance,
I have a class which implements UserControl. In .NET 2005, a Dispose method is
I'm using .NET 3.5 and I have a class, A, marked as internal sealed

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.