You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
publicclassSampleEventArgs{publicSampleEventArgs(strings){Text=s;}publicStringText{get;}// readonly}publicclassPublisher{// Declare the delegate (if using non-generic pattern).publicdelegatevoidSampleEventHandler(objectsender,SampleEventArgse);// Declare the event.publiceventSampleEventHandlerSampleEvent;// Wrap the event in a protected virtual method// to enable derived classes to raise the event.protectedvirtualvoidRaiseSampleEvent(){// Raise the event in a thread-safe manner using the ?. operator.SampleEvent?.Invoke(this,newSampleEventArgs("Hello"));}}
On line 4, there is an issue. String is capitalized when it shouldn't be.
publicStringText{get;}// readonly
It should be
publicstringText{get;};// readonly
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
ID: f782a9c5-2dc8-d8d1-b17d-246ab8524863
Version Independent ID: f6f825c5-c64b-d13b-1c7e-a01bfb93093d
Hi @SamBehner - thank you for posting this issue. As long as there was a using System; at the top of the C# file - it is fine to use String, as string is an alias to the proper System type. But I agree, and I do prefer string. I've marked this issue as "up-for-grabs", feel free to create a pull request to address this issue and we'll happily review it.
Also, one small correction - you added an extra ; at the end which is not needed. Should be this:
Oh, I was not aware oh this. I think it would be better to use string though as it seems more common, and it would match most of the other examples in the documentation
Activity
IEvangelist commentedon Jun 2, 2020
Hi @SamBehner - thank you for posting this issue. As long as there was a
using System;at the top of the C# file - it is fine to useString, asstringis an alias to the properSystemtype. But I agree, and I do preferstring. I've marked this issue as "up-for-grabs", feel free to create a pull request to address this issue and we'll happily review it.Also, one small correction - you added an extra
;at the end which is not needed. Should be this:Sampleeeee commentedon Jun 2, 2020
Oh, I was not aware oh this. I think it would be better to use
stringthough as it seems more common, and it would match most of the other examples in the documentationMinor code cleanup
Minor code cleanup (#18773)