While performing a refactoring, I ended up creating a method like the example below. The datatype has been changed for simplicity's sake.
I previous had an assignment statement like this:
MyObject myVar = new MyObject();
It was refactored to this by accident:
private static new MyObject CreateSomething()
{
return new MyObject{"Something New"};
}
This was a result of a cut/paste error on my part, but the new
keyword in private static new
is valid and compiles.
Question: What does the new
keyword signify in a method signature? I assume it's something introduced in C# 3.0?
How does this differ from override
?