static private AllCaseBodiesMustHaveSameType ( string paramName ) : |
||
paramName | string | |
Результат |
/// <summary> /// If custom type is provided, all branches must be reference assignable to the result type. /// If no custom type is provided, all branches must have the same type - resultType. /// </summary> private static void ValidateSwitchCaseType(Expression @case, bool customType, Type resultType, string parameterName) { if (customType) { if (resultType != typeof(void)) { if (!TypeUtils.AreReferenceAssignable(resultType, @case.Type)) { throw Error.ArgumentTypesMustMatch(parameterName); } } } else { if (!TypeUtils.AreEquivalent(resultType, @case.Type)) { throw Error.AllCaseBodiesMustHaveSameType(parameterName); } } }