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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:19:42+00:00 2026-05-26T17:19:42+00:00

I was recently writing some code to do WriteLine using a delegate in .NET

  • 0

I was recently writing some code to do WriteLine using a delegate in .NET 3.5.
It was all going well using various different Action delegates until I came to the overload of WriteLine which is

public static void WriteLine(string format, object arg0, object arg1, object arg2, object arg3)

As I’m using .NET 3.5 there is no Action<T1, T2, T3, T4, T5> delegate so I quicly wrote my own:

public delegate void Action<T1, T2, T3, T4, T5>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5);

I then went to assign WriteLine to this method Action<string, object, object, object, object> action = Console.WriteLine; and I got the error message

No overload for ‘WriteLine’ matches delegate ‘Action<string,object,object,object,object>’

I thought this must be caused as a result of some generics issue so I explicitly declared a new delegate:

public delegate void WriteLineAction(string format, object arg0, object arg1, object arg2, object arg3);

I then tried assigning WriteLine to this new method and again got the error message:

No overload for ‘WriteLine’ matches delegate ‘WriteLineAction’

The even stranger thing is that if I right click on the Console.WriteLine call that’s in error and say “Go To Definition” it takes me to the right version of WriteLine in the metadata, so why is it not able to match the method to the delegate. Am I doing something really stupid here or is this a known issue / feature?

  • 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-26T17:19:43+00:00Added an answer on May 26, 2026 at 5:19 pm

    If you look at the docs for this overload it shows:

    This API is not CLS-compliant. The CLS-compliant alternative is WriteLine(String, Object[]).

    and if you look at the C# tab in the signature, it says:

    C# does not support methods that use variable length arguments (varargs).
    The compiler automatically resolves calls to this method to the same method that uses a parameter array.

    The C++ tab shows the signature as:

    public:
    static void WriteLine(
        String^ format, 
        Object^ arg0, 
        Object^ arg1, 
        Object^ arg2, 
        Object^ arg3, 
        ...
    )
    

    I strongly suspect this is the issue. In Reflector it shows up as:

    public static void WriteLine(string format, object arg0, object arg1,
        object arg2, object arg3, __arglist)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Recently I spent quite some time writing various Visual Studio Extensions projects. Even though
So I'm writing some code and have recently come across the need to implement
I've recently been writing some code for a research project that I'm working on,
I have a question. I was recently writing some javascript code in dreamweaver and
I've recently become interested in writing some system services for OS X but since
I recently found myself writing a piece of code that executed a Core Data
I recently began profiling an osgi java application that I am writing using VisualVM.
I've recently been writing some basic command-line programs (I want to keep my skills
I recently inherited some code that someone else had written. I discovered that everywhere
I was working on some code recently and decided to work on my operator

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.