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

  • Home
  • SEARCH
  • 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 7174259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:59:51+00:00 2026-05-28T15:59:51+00:00

I have a method declared on an interface like so: public interface IInterface {

  • 0

I have a method declared on an interface like so:

public interface IInterface
{
    void DoSomething(string format, params object[] arguments);
}

I am dynamically loading a managed c++ class that uses an implementation of this interface. The interface and inmplementation are both C#.

IInterface^ foo = gcnew Implentation();

This call is fine:

foo->DoSomething("string", someParam);

This call fails:

foo->DoSomething("string");

It looks like if there are no parameters to pass it just can’t resolve the method which should accept any number of params (including zero of course). I could probably use a nullptr as a placeholder but that’s pretty ugly or I could add a superfluous overload of DoSomething(string format) which isn’t great either but better than making all calls more awkward than they should be.

Am I missing something or is this not supported? All the helpers on the internet show how to declare the params equivalent in c++ but that doesn’t help in my scenario.

  • 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-28T15:59:52+00:00Added an answer on May 28, 2026 at 3:59 pm

    I can’t replicate your problem.

    Given the C# interface & implementation:

    using System;
    
    namespace SomeNamespace
    {
        public interface IInterface
        {
            void Print(string format, params object[] args);
        }
    
        public class Implementation : IInterface
        {
            public void Print(string format, params object[] args)
            {
                Console.WriteLine(format, args);
            }
        }
    }
    

    This C++/CLI code works fine:

    using namespace System;
    using namespace SomeNamespace;
    
    public ref class Test
    {
    public:
        static void Run()
        {
            IInterface^ foo = gcnew Implementation();
            foo->Print("hello, {0}", "world");
            foo->Print("hello, world");
        }
    };
    

    Is there another element that is missing here? Or have I missed the point 🙂

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

Sidebar

Related Questions

I have an interface like below public interface FooDAO { public void callA(String x);
I have a C# interface with certain method parameters declared as object types. However,
I have a method which takes params object[] such as: void Foo(params object[] items)
I have an interface defining a method like this : public List<IA> myMethod(); with
And i have one interface public interface IMethod { String Add(string str); Boolean Update(string
I have an interface declared as follows public interface ILoadObjects<T> where T : class
I have class1.m . I declared a method and written in it. Now i
I have a method that can return either a single object or a collection
I've implemented a class that looks like this interface: [ImmutableObject(true)] public interface ICustomEvent {
I have a variable declared in the header file : @interface int _nPerfectSlides; and

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.