toString() no suitable method found to override
I'm banging my head here..
Given in C#...
public class ClassA
{
public override string toString()
{
return开发者_运维知识库 "use this toString()!";
}
}
When I try to build this it tells me: "ClassA.toString(): no suitable method found to override."
How do you override the default toString in C# if not this?
The correct method is ToString
It's ToString (with a capital T) that you're after. Contrary to other languages such as Java, C# generally has method names starting with capitals. And like other languages such as Java, it is case sensitive!
Are you coming from a Java background by any chance? :-)
精彩评论