Jason Loki Smith
Jason Loki Smith

Reputation: 438

Difference between "public new void Method()" and "new public void Method() in C#

I stumbled across this post here explaining how you can hide inherited members or override their values. (I was investigating the possibility of changing access modifiers when using inheritance, yes it isn't possible and it makes sense why it isn't possible - that's not part of the question, do not judge)

This is quite an old feature in C# i know.

My question is that the syntax i have always known to achieve this behaviour was

public new void SomeMethod()

Instead this article uses the syntax:

new public void SomeMethod() 

Again, assume in this scenario there is some inheritance applied here and i actually want to change the behaviour of "SomeMethod"

My Question to the SO community is what is the difference between the above 2 statements? I have tried to investigate it but i cannot find an answer.

Upvotes: 0

Views: 322

Answers (0)

Related Questions