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
?
It means the method replaces a method by the same name inherited by the base class. In your case, you probably don't have a method by that name in the base class, meaning the new keyword is totally superfluous.
From MSDN: