Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Foo
- {
- public void Bar(IEnumerable x);
- }
- public class Foo
- {
- public void Bar(IEnumerable x);
- public void Bar(ICloneable x);
- }
- new Foo().Bar(new int[0]);
- public class Foo
- {
- public static implicit operator int ();
- }
- public class Foo
- {
- public static implicit operator int ();
- public static implicit operator float ();
- }
- void Bar(int x);
- void Bar(float x);
- Bar(new Foo());
- public class Foo
- {
- }
- public class Foo
- {
- public void Bar();
- }
- public static class FooExtensions
- {
- public void Bar(this Foo foo);
- }
- new Foo().Bar();
- public static class Foo
- {
- public static void bar(int i);
- }
- public static class Foo
- {
- public static bool bar(int i);
- }
- Foo.bar(13);
- public void Foo(int a) { }
- public void Foo(int a, string b = null) { }
- Foo(5);
- class Foo
- {
- public virtual void Bar() {}
- public virtual void Baz() {}
- }
- class FooBase
- {
- public virtual void Bar() {}
- }
- class Foo : FooBase
- {
- public virtual void Baz() {}
- }
- // C++/CLI
- ref class Derived : Foo
- {
- public virtual void Baz() {{
- // Explicit override
- public virtual void BarOverride() = Foo::Bar {}
- };
- interface IFoo
- {
- void Bar();
- void Baz();
- }
- interface IFooBase
- {
- void Bar();
- }
- interface IFoo : IFooBase
- {
- void Baz();
- }
- class Foo : IFoo
- {
- void IFoo.Bar() { ... }
- void IFoo.Baz() { ... }
- }
- (new Foo()).Bar();
- public enum Foo
- {
- Bar,
- Baz
- }
- public enum Foo
- {
- Baz,
- Bar
- }
- Foo.Bar < Foo.Baz
- public class Foo
- {
- }
- public class Foo
- {
- public void Frob() {}
- }
- class Bar
- {
- public void Frob() {}
- }
- class Program
- {
- static void Qux(Action<Foo> a)
- {
- }
- static void Qux(Action<Bar> a)
- {
- }
- static void Main()
- {
- Qux(x => x.Frob());
- }
- }
- public class Foo : IEnumerable
- {
- public IEnumerator GetEnumerator();
- }
- public class Foo : IEnumerable
- {
- IEnumerator IEnumerable.GetEnumerator();
- }
- new Foo().GetEnumerator(); // fails because GetEnumerator() is no longer public
- public class Foo : IEnumerable
- {
- IEnumerator IEnumerable.GetEnumerator() { yield return "Foo"; }
- }
- public class Foo : IEnumerable
- {
- public IEnumerator GetEnumerator() { yield return "Foo"; }
- }
- class Bar : Foo, IEnumerable
- {
- IEnumerator IEnumerable.GetEnumerator() // silently hides base instance
- { yield return "Bar"; }
- }
- foreach( var x in new Bar() )
- Console.WriteLine(x); // originally output "Bar", now outputs "Foo"
- Public Class Foo
- Public Shared Bar As String = ""
- End Class
- Public Class Foo
- Private Shared _Bar As String = ""
- Public Shared Property Bar As String
- Get
- Return _Bar
- End Get
- Set(value As String)
- _Bar = value
- End Set
- End Property
- End Class
- Foo.Bar = "foobar"
- Imports System
- Imports Api.SomeNamespace
- Public Class Foo
- Public Sub Bar()
- Dim dr As Data.DataRow
- End Sub
- End Class
- namespace SomeNamespace {
- public class Foo {
- public static void Bar(string x) {
- ...
- }
- }
- }
- namespace SomeNamespace {
- public class Foo {
- public static void Bar(string y) {
- ...
- }
- }
- }
- Api.SomeNamespace.Foo.Bar(x:"hi"); //C#
- Api.SomeNamespace.Foo.Bar(x:="hi") 'VB
- namespace SomeNamespace {
- public class Foo {
- public static void Bar(string x) {
- ...
- }
- }
- }
- namespace SomeNamespace {
- public class Foo {
- public static void Bar(string x) {
- ...
- }
- public static void Bar(ref string x) {
- ...
- }
- }
- }
- Api.SomeNamespace.Foo.Bar(str)
- namespace SomeNamespace {
- public class Foo {
- public int Bar;
- }
- }
- namespace SomeNamespace {
- public class Foo {
- public int Bar { get; set; }
- }
- }
- FooBar(ref Api.SomeNamespace.Foo.Bar);
- protected void Something<T>() where T : Class2 { }
- protected class Class3 : Class2 { }
- protected void Something<T>() where T : Class3 { }
- public int MyMethod(int mandatoryParameter, int optionalParameter = 0)
- {
- return mandatoryParameter + optionalParameter;
- }
- public int MyMethod(int mandatoryParameter, int optionalParameter)
- {
- return mandatoryParameter + optionalParameter;
- }
- public int MyMethod(int mandatoryParameter)
- {
- return MyMethod(mandatoryParameter, 0);
- }
- public int CodeNotDependentToNewVersion()
- {
- return MyMethod(5, 6);
- }
- public int CodeDependentToNewVersion()
- {
- return MyMethod(5);
- }
- public interface IFoo
- {
- void Test();
- }
- public class Bar
- {
- IFoo GetFoo() { return new Foo(); }
- }
- public interface IFooNew // Of the exact same definition as the (old) IFoo
- {
- void Test();
- }
- public class Bar
- {
- IFooNew GetFoo() { return new Foo(); }
- }
- new Bar().GetFoo().Test(); // Binary only break
- IFoo foo = new Bar().GetFoo(); // Source and binary break
- public static class Foo
- {
- public static void Bar(string x);
- }
- public static class Foo
- {
- public void Bar(this string x);
- }
- using static Foo;
- class Program
- {
- static void Main() => Bar("hello");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement