MicrosoftDocs / feedback

📢 docs.microsoft.com site feedback
https://learn.microsoft.com
Creative Commons Attribution 4.0 International
239 stars 160 forks source link

Use of String and string in coding examples #2974

Open Jymms opened 4 years ago

Jymms commented 4 years ago

Beginners find it very confusing when the examples of code uses 'String' and when put into Visual Studio, the IDE suggests they use 'string' instead.

Describe the solution you'd like Some comment stating that 'String' is the proper variable to be using.

Additional context https://docs.microsoft.com/en-us/dotnet/api/system.componentmodel.inotifypropertychanged.propertychanged?view=netcore-3.1

One would think this page is updated because it's exampling the new core 3.1 but in many cases it uses String when it should be string.
Examples: private string customerNameValue = String.Empty; private void NotifyPropertyChanged([CallerMemberName] String propertyName = "")

Not easy to explain to kids after teaching them string <> String.

welcome[bot] commented 4 years ago

Thank you for creating the issue! One of our team members will get back to you shortly with additional information. If this is a product issue, please close this and contact the particular product's support instead (see https://support.microsoft.com/allproducts for the list of support websites).

Youssef1313 commented 4 years ago

To clear up your confusion, both should work the same. It's a matter of coding style. However, as Visual Studio suggested, string is the more common convention.

I opened https://github.com/dotnet/dotnet-api-docs/pull/4602 to fix this.

Jymms commented 4 years ago

Not sure why you think I'm confused, I know that string is an alias of System.String. I'm attempting to help make the docs easier to use for beginners that shouldn't need to read private string customerNameValue = String.Empty; then have the IDE tell them String can be simplified by using "string", which then turns into 30 mins of attempting to find out why they should use string instead of String with a lot of confusing explanations for beginners.

rootsmusic commented 3 years ago

@lymms You can submit feedback by clicking on the button at the bottom of https://docs.microsoft.com/en-us/contribute/code-in-docs