diff --git a/docs/csharp/misc/cs1031.md b/docs/csharp/misc/cs1031.md index a0f10410b899f..c945de1b0607e 100644 --- a/docs/csharp/misc/cs1031.md +++ b/docs/csharp/misc/cs1031.md @@ -12,35 +12,32 @@ ms.assetid: 14196659-aaac-4df2-a4ed-0bebb8097d59 Type expected - A type parameter is expected. - -## Example +A type has not been specified where expected, when [overloading an operator](../language-reference/operators/operator-overloading.md). +
Missing *type* in this case means that there's no *type* given for the return type of the overloaded operator. +This error shouldn't be confused with missing [generic type parameter](../../csharp/programming-guide/generics/generic-type-parameters.md). - The following sample generates CS1031: - -```csharp -// CS1031.cs -namespace x -{ - public class ii - { - } - - public class a +## Example + +The following sample generates CS1031: + +```csharp +namespace x +{ + public class I + { + } + + public class A { - public static operator +(a aa) // CS1031 - // try the following line instead - // public static ii operator +(a aa) - { - return new ii(); - } - - public static void Main() - { - e = new base; // CS1031, not a type - e = new this; // CS1031, not a type - e = new (); // CS1031, not a type - } - } -} + public static operator +(A a) // CS1031 - Overloaded operator missing a type + { + return new I(); + } + + public static I operator +(A a) // Correct - type was specified + { + return new I(); + } + } +} ```