Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Cannot convert type 'type' to 'type'
You must provide conversion routines to support certain operator overloads. For more information, see Conversion Operators (C# Programming Guide).
The following sample generates CS0030:
// CS0030.cs
namespace Conversions
{
public class MyType
{
// The following operators define conversions from an integer to
// MyType and from MyType to an integer.
/*
public static implicit operator MyType(int anArg)
{
return null;
}
public static implicit operator int(MyType anArg)
{
return 0;
}
*/
// The following operator definition causes a compiler error because the
// conversion operator that converts from type int to type MyType is
// commented out.
public static MyType operator ++(MyType aa)
{
return (MyType)0; // CS0030
// Uncomment the conversion routines to resolve the error.
}
public static void Main()
{
}
}
}
Change History
Date |
History |
Reason |
---|---|---|
July 2009 |
Expanded the example. |
Customer feedback. |