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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:57:59+00:00 2026-05-11T17:57:59+00:00

The code below generates a warning CS3006 Overloaded method MyNamespace.Sample.MyMethod(int[])’ differing only in ref

  • 0

The code below generates a warning CS3006 “Overloaded method MyNamespace.Sample.MyMethod(int[])’ differing only in ref or out, or in array rank, is not CLS-compliant”.

Is this warning valid, i.e. is this genuinely not CLS-compliant? I’d have thought an explicit interface implementation would not count as an overload.

[assembly: CLSCompliant(true)]
namespace MyNamespace
{

    public class Sample : ISample
    {
        public void MyMethod(int[] array)
        {
            return;
        }

        void ISample.MyMethod(ref int[] array)
        {
            this.MyMethod(array);
        }
    }

    public interface ISample
    {
        void MyMethod([In] ref int[] array);
    }
}
  • 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-11T17:57:59+00:00Added an answer on May 11, 2026 at 5:57 pm

    CLS compliance only applies to the visible part of your class. Therefore, you’d think that the ref int[] is not public and therefore not relevant. But it is visible, through the interface.

    The users of your code know that Sample provides void MyMethod(int[]). They also know that it implements ISample which provides void MyMethod(ref int[]). Therefore, I believe it is in fact not CLS-Compliant.


    EDIT: Eric Lippert has commented on the original question that he believes this is in fact a compiler bug and that the original code is CLS-Compliant.


    This, however, is valid:

    [assembly: CLSCompliant(true)]
    namespace MyNamespace
    {
        public class Sample : ISample, ISample2
        {
            void ISample.MyMethod(ref int[] array)
            {
            }
    
            void ISample2.MyMethod(int[] array)
            {
            }
        }
    
        public interface ISample
        {
            void MyMethod(ref int[] array);
        }
    
        public interface ISample2
        {
            void MyMethod(int[] array);
        }
    }
    

    That is because CLS defines that two interface may define conflicting methods with the same name or signature and the compiler must know how to tell the difference – but again, only when the conflict is between two interfaces.

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

Sidebar

Ask A Question

Stats

  • Questions 214k
  • Answers 214k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Ok I think we found the answer, and evidently it's… May 12, 2026 at 10:51 pm
  • Editorial Team
    Editorial Team added an answer What you're describing is essentially OLAP - Online Analytical Processing.… May 12, 2026 at 10:51 pm
  • Editorial Team
    Editorial Team added an answer I suggest you create a virtual machine with a server… May 12, 2026 at 10:51 pm

Related Questions

The code below generates a warning CS3006 Overloaded method MyNamespace.Sample.MyMethod(int[])' differing only in ref
Named local classes are very rarely used, usually local classes are anonymous. Does anybody
I recently was making a change to to our codebase from float to long
The Visual Studio compiler does not seem to warn on signed/unsigned assignments, only on
In ANTLR version 2.X you could specify something was to go before or after

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.