ProblemBook.NET
  • ProblemBook.NET
  • LANGS
  • Задачник.NET
    • Math
      • «AugmentedAssignment» (Задача)
      • «Rounding1» (Задача)
      • «Overflow» (Решение)
      • «Overflow» (Задача)
      • «DivideByZero» (Решение)
      • «DivideByZero» (Задача)
      • «Eps» (Решение)
      • «DynamicIncrement» (Решение)
      • «Eps» (Задача)
      • «DynamicIncrement» (Задача)
      • «Rounding2» (Решение)
      • «AugmentedAssignment» (Решение)
      • «Rounding1» (Решение)
      • «Rounding2» (Задача)
    • Oop
      • «InheritanceNestedClass» (Задача)
      • «OverloadResolutionBasic» (Решение)
      • «OverloadResolutionOverride» (Решение)
      • «OverloadResolutionBasic» (Задача)
      • «OverloadResolutionOverride» (Задача)
      • «OverloadResolutionInheritance» (Решение)
      • «OverloadResolutionInheritance» (Задача)
      • «StaticFieldInGenericType» (Решение)
      • «StaticFieldInGenericType» (Задача)
      • «InheritanceNestedClass» (Решение)
    • ValueTypes
      • «Enumerator» (Решение)
      • «MutableProperty» (Задача)
      • «Enumerator» (Задача)
      • «StructLayout» (Решение)
      • «StructLayout» (Задача)
      • «Boxing» (Решение)
      • «Boxing» (Задача)
      • «MutableProperty» (Решение)
    • Strings
      • «InternmentAndMetadata» (Решение)
      • «CorruptedNumber» (Решение)
      • «InternmentAndMetadata» (Задача)
      • «TextElementEnumerator» (Решение)
      • «CorruptedNumber» (Задача)
      • «CaseInComparison» (Решение)
      • «TextElementEnumerator» (Задача)
      • «CaseInComparison» (Задача)
      • «StableSorting» (Решение)
      • «Secure» (Решение)
      • «CurrentCulture» (Решение)
      • «StableSorting» (Задача)
      • «Secure» (Задача)
      • «StringPlusNull» (Решение)
      • «CurrentCulture» (Задача)
      • «ExplicitlyInternment» (Решение)
      • «PlusChar» (Решение)
      • «StringPlusNull» (Задача)
      • «ExplicitlyInternment» (Задача)
      • «PlusChar» (Задача)
      • «NoStringInterning» (Решение)
      • «CorruptedString» (Решение)
      • «PlusString» (Решение)
      • «CompareToVsEquals» (Решение)
      • «NoStringInterning» (Задача)
      • «PlusString» (Задача)
      • «CorruptedString» (Задача)
      • «CompareToVsEquals» (Задача)
    • Linq
      • «QueryAfterRemove» (Решение)
      • «ClosureAndVariable» (Решение)
      • «QueryAfterRemove» (Задача)
      • «ClosureAndVariable» (Задача)
      • «EnumerableToArray» (Решение)
      • «QueryWithInc» (Решение)
      • «EnumerableToArray» (Задача)
      • «QueryWithInc» (Задача)
      • «LifeAfterYield» (Решение)
      • “YieldExceptionYield” (Решение)
      • «LifeAfterYield» (Задача)
      • «ExceptionYieldYield» (Решение)
      • «ClosureAndForeach» (Решение)
      • «TryYieldFinally» (Задача)
      • «ClosureAndFor» (Решение)
      • «ExceptionYieldYield» (Задача)
      • «YieldExceptionYield» (Решение)
      • «ClosureAndForeach» (Задача)
      • «ClosureAndFor» (Задача)
      • «YieldExceptionYield» (Задача)
    • Multithreading
      • «ThreadStaticVariable» (Решение)
      • «ThreadStaticVariable» (Задача)
      • «LockSlimInFinalizer» (Решение)
      • «LockSlimInFinalizer» (Задача)
    • Summary
    • Введение
  • ProblemBook.NET
    • Oop
      • “OverloadResolutionInheritance” (Solution)
      • “InheritanceNestedClass” (Solution)
      • “OverloadResolutionInheritance” (Problem)
      • “InheritanceNestedClass” (Problem)
      • “OverloadResolutionOverride” (Solution)
      • “OverloadResolutionOverride” (Problem)
      • “StaticFieldInGenericType” (Solution)
      • “OverloadResolutionBasic” (Solution)
      • “StaticFieldInGenericType” (Problem)
      • “OverloadResolutionBasic” (Problem)
    • Strings
      • “CorruptedNumber” (Problem)
      • “PlusString” (Solution)
      • “TextElementEnumerator” (Problem)
      • “PlusString” (Problem)
      • “StableSorting” (Solution)
      • “StableSorting” (Problem)
      • “CaseInComparison” (Solution)
      • “CaseInComparison” (Problem)
      • “NoStringInterning” (Solution)
      • “Secure” (Solution)
      • “CorruptedString” (Solution)
      • “CompareToVsEquals” (Solution)
      • “CurrentCulture” (Solution)
      • “NoStringInterning” (Problem)
      • “Secure” (Problem)
      • “CorruptedString” (Problem)
      • “CompareToVsEquals” (Problem)
      • “StringPlusNull” (Solution)
      • “CurrentCulture” (Problem)
      • “ExplicitlyInternment” (Solution)
      • “PlusChar” (Solution)
      • “InternmentAndMetadata” (Solution)
      • “CorruptedNumber” (Solution)
      • “StringPlusNull” (Problem)
      • “ExplicitlyInternment” (Problem)
      • “PlusChar” (Problem)
      • “InternmentAndMetadata” (Problem)
      • “TextElementEnumerator” (Solution)
    • Linq
      • “YieldExceptionYield” (Problem)
      • “QueryAfterRemove” (Problem)
      • “ClosureAndVariable” (Problem)
      • “QueryWithInc” (Solution)
      • “QueryWithInc” (Problem)
      • “LifeAfterYield” (Solution)
      • “LifeAfterYield” (Problem)
      • “EnumerableToArray” (Solution)
      • “EnumerableToArray” (Problem)
      • «YieldExceptionYield» (Solution)
      • “ExceptionYieldYield” (Solution)
      • “ClosureAndForeach” (Solution)
      • “TryYieldFinally” (Problem)
      • “ClosureAndFor” (Solution)
      • “ExceptionYieldYield” (Problem)
      • “YieldExceptionYield” (Solution)
      • “ClosureAndForeach” (Problem)
      • “ClosureAndVariable” (Solution)
      • “QueryAfterRemove” (Solution)
      • “ClosureAndFor” (Problem)
    • Multithreading
      • “ThreadStaticVariable” (Solution)
      • “LockSlimInFinalizer” (Solution)
      • “ThreadStaticVariable” (Problem)
      • “LockSlimInFinalizer” (Problem)
    • ValueTypes
      • “StructLayout” (Problem)
      • “MutableProperty” (Solution)
      • “Boxing” (Solution)
      • “MutableProperty” (Problem)
      • “Boxing” (Problem)
      • “Enumerator” (Solution)
      • “Enumerator” (Problem)
      • “StructLayout” (Solution)
    • Math
      • “Rounding2” (Solution)
      • “AugmentedAssignment” (Solution)
      • “Rounding1” (Solution)
      • “Rounding2” (Problem)
      • “Rounding1” (Problem)
      • “AugmentedAssignment” (Problem)
      • “DivideByZero” (Solution)
      • “DivideByZero” (Problem)
      • “DynamicIncrement” (Solution)
      • “DynamicIncrement” (Problem)
      • “Eps” (Solution)
      • “Eps” (Problem)
      • “Overflow” (Solution)
      • “Overflow” (Problem)
    • Summary
    • Introduction
  • Attribution-NonCommercial-NoDerivatives 4.0 International
Powered by GitBook
On this page
  • Answer
  • Explanation
  • Links

Was this helpful?

  1. ProblemBook.NET
  2. Oop

“OverloadResolutionBasic” (Solution)

Answer

params object[]
params object[]
params T[]
params T[]
object, object

Explanation

There are methods:

  • void Foo(object a) -> object

  • void Foo(object a, object b) -> object, object

  • void Foo(params object[] args) -> params object[]

  • void Foo<T>(params T[] args) -> params T[]

Let's consider each call separately.

  • Foo() -> params object[]

The object and object, object options is inaccessible because of number of arguments. The params T[] option is inaccessible because of the compiler can't resolve T. Thus, the right options is params object[].

  • Foo(null) -> params object[]

The object, object option is inaccessible because of number of arguments. The params T[] options is inaccessible because of the compiler can't resolve T. The params object[] option is acceptable in its expanded and unexpanded forms. In this case, we should choose the expanded form, i.e. the method signature will look like Foo(object[] args). Now, we have the object and object[] options. The compiler will choose more specific option, i.e. object[] (or params object[]).

  • Foo(new Bar()) -> params T[]

The object, object option is inaccessible because of number of arguments. The object and params object[] options request an additional implicitly conversion: Bar to object. So, the params T[] (or params Bar[]) option is more preferable.

  • Foo(new Bar(), new Bar()) -> params T[]

The object option is inaccessible because of number of arguments. The object, object and params object[] options request an additional implicitly conversion: Bar to object. So, the params T[] (or params Bar[]) option is more preferable.

  • Foo(new Bar(), new object()) -> object, object

The object option is inaccessible because of number of arguments. There is exactly one option without the params keyword: object, object. It is more preferable.

Links

Previous“StaticFieldInGenericType” (Solution)Next“StaticFieldInGenericType” (Problem)

Last updated 6 years ago

Was this helpful?

, in MSDN

in

“Overload resolution”
“Applicable function member”
“Overloading”
“C# in Depth”
Problem