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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:05:54+00:00 2026-05-30T03:05:54+00:00

I saw Jon Skeet’s lecture at the NDC 2010 He mentioned something interesting :

  • 0

I saw Jon Skeet’s lecture at the NDC 2010

He mentioned something interesting :

public Class Base
{
 public void Foo(IEnumerable<string> strings){}
}

public Class Child:Base
{
 publc void Foo(IEnumerable<object> objects) {}
}

Main :

List<string> lst = new List<string>();
lst.Add("aaa");
Child c = new Child();
c.Foo(lst);

With C# 3 it will call : Base.Foo

With C# 4 it will call : Child.Foo

I know it’s because covariance

Question :

Isn’t it a bit code breaking change ?
Is there any workaround so this code will continue work as it was on ver 3?

  • 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-30T03:05:55+00:00Added an answer on May 30, 2026 at 3:05 am

    Yes, it’s a breaking change. Any time you make a prevously-invalid conversion legal, it’s a breaking change.

    Unfortunately, it’s very hard to add features to the language without making any breaking changes. There are a few more around events in C# 4 if you really want to look for them. It’s unlikely that these will affect most developers, of course.

    There were similar breaking changes between C# 1 and C# 2, where the implementation used would have changed between different versions for this code:

    using System;
    
    public delegate void StringAction(string x);
    
    public class Base
    {
        public void Foo(string x)
        {
            Console.WriteLine("Base");
        }
    }
    
    public class Child : Base
    {
        public void Foo(object x)
        {
            Console.WriteLine("Child");
        }
    }
    
    public class Test
    {
        static void Main()
        {
            Child c = new Child();
            StringAction action = new StringAction(c.Foo);
            action("x");
        }
    }
    

    In this case the compiler actually gives a warning:

    Test.cs(26,31): warning CS1707: Delegate 'StringAction' bound to
            'Child.Foo(object)' instead of 'Base.Foo(string)' because of new
            language rules
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I saw the following code snippet: class WindowHandle { public: WindowHandle(WINDOW_HANDLE handle) : w(handle)
I saw this reply from Jon on Initialize generic object with unknown type :
I saw this same question for VIM and it has been something that I
Saw this line in a class method and my first reaction was to ridicule
Saw this signature today: public interface ISomeInterface<in T> What impact does the in parameter
I saw someone using this in one answer: void methodA(const int*& var); I couldn't
i saw somewhere in GWT code , it was something like this assert display
saw the following in some .rb file name something why not using assignment like
Saw an interesting piece of code recently, and my mind made a snap judgement
I saw a class AttributeSelectedClassifier was once created in the following ways: AttributeSelectedClassifier classifier

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.