E
E
Evgeny Ivanov2020-08-29 16:13:51
C++ / C#
Evgeny Ivanov, 2020-08-29 16:13:51

Why do method names in Visual Studio have different CamelCase syntax by default?

Visual Studio 2019

Double click on button creates view method

private void button1_Click(object sender, EventArgs e)

By default, in Win Forms, the button has the name button1, respectively, and the name of the button1_Click method.

at the same time, it is customary in Microsoft .NET to use UpperCamelCase for naming classes and methods.
And many WPF examples and tutorials write
private void Button_Click(object sender, RoutedEventArgs e)


Of course, either works. But very often the name of a method in Win Forms begins with a small letter, due to the automatic naming of elements by Visual Studio with a small letter.
Yes, we can change the name. But by default, the studio will give a name and create a method for it with a small letter.

What is it connected with?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
Gennady Kruglov, 2020-08-29
@logpol32

As far as I remember - a very long time ago, Microsoft was recommended to adhere to the common naming style when private methods are written in CamelCase (by the way, it's not a fact that this is bad and why they left it - the question is). But then Microsoft apparently decided that they were special and they should have everything in Pascal. And we updated the style guide on msdn .
Perhaps they simply forgot about WinForms and did not begin to redo the automatic code generation to fit their own style requirements.
PS:
At Microsoft itself, if you look at the interfaces and implementation of .NET libraries, naming in CamelCase is often found.

V
Vladimir Korotenko, 2020-08-29
@firedragon

So historically, they apparently decided not to change this.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question