diff --git a/docs/standard/datetime/access-utc-and-local.md b/docs/standard/datetime/access-utc-and-local.md index 325af99537069..574d4a6152a91 100644 --- a/docs/standard/datetime/access-utc-and-local.md +++ b/docs/standard/datetime/access-utc-and-local.md @@ -6,12 +6,12 @@ dev_langs: - "csharp" - "vb" helpviewer_keywords: - - "time zones [.NET Framework], local" + - "time zones [.NET], local" - "predefined time zones" - "UTC times, predefined" - "local time zone access" - - "time zones [.NET Framework], retrieving" - - "time zones [.NET Framework], UTC" + - "time zones [.NET], retrieving" + - "time zones [.NET], UTC" ms.assetid: 961fb70b-83f0-4dab-a042-cb5fcd817cf5 --- # How to: Access the predefined UTC and local time zone objects diff --git a/docs/standard/datetime/choosing-between-datetime.md b/docs/standard/datetime/choosing-between-datetime.md index fa9a6e5dd2240..d3ce8caa53b56 100644 --- a/docs/standard/datetime/choosing-between-datetime.md +++ b/docs/standard/datetime/choosing-between-datetime.md @@ -9,9 +9,9 @@ dev_langs: helpviewer_keywords: - "DateTimeOffset structure" - "TimeZoneInfo class" - - "time zones [.NET Framework], common uses" - - "date and time classes [.NET Framework]" - - "time zones [.NET Framework], type options" + - "time zones [.NET], common uses" + - "date and time classes [.NET]" + - "time zones [.NET], type options" - "DateTime structure" ms.assetid: 07f17aad-3571-4014-9ef3-b695a86f3800 --- diff --git a/docs/standard/datetime/converting-between-datetime-and-offset.md b/docs/standard/datetime/converting-between-datetime-and-offset.md index 2239aaaa998af..29184dae9b6bc 100644 --- a/docs/standard/datetime/converting-between-datetime-and-offset.md +++ b/docs/standard/datetime/converting-between-datetime-and-offset.md @@ -8,11 +8,11 @@ dev_langs: - "vb" helpviewer_keywords: - "DateTime structure, converting" - - "time zones [.NET Framework], conversions" + - "time zones [.NET], conversions" - "UTC times, converting" - "DateTimeOffset structure, converting" - "converting DateTimeOffset and DateTime values" - - "dates [.NET Framework], converting" + - "dates [.NET], converting" - "converting times" - "Date data type, converting" - "local time conversions" diff --git a/docs/standard/datetime/converting-between-time-zones.md b/docs/standard/datetime/converting-between-time-zones.md index ad70e7531e28b..3e43e087fbe76 100644 --- a/docs/standard/datetime/converting-between-time-zones.md +++ b/docs/standard/datetime/converting-between-time-zones.md @@ -7,8 +7,8 @@ dev_langs: - "csharp" - "vb" helpviewer_keywords: - - "times [.NET Framework], converting" - - "time zones [.NET Framework], conversions" + - "times [.NET], converting" + - "time zones [.NET], conversions" - "UTC times, converting" - "converting times" - "local time conversions" @@ -20,7 +20,7 @@ It is becoming increasingly important for any application that works with dates ## Converting to Coordinated Universal Time -Coordinated Universal Time (UTC) is a high-precision, atomic time standard. The world’s time zones are expressed as positive or negative offsets from UTC. Thus, UTC provides a kind of time-zone free or time-zone neutral time. The use of UTC time is recommended when a date and time's portability across computers is important. (For details and other best practices using dates and times, see [Coding best practices using DateTime in the .NET Framework](/previous-versions/dotnet/articles/ms973825(v=msdn.10)).) Converting individual time zones to UTC makes time comparisons easy. +Coordinated Universal Time (UTC) is a high-precision, atomic time standard. The world's time zones are expressed as positive or negative offsets from UTC. Thus, UTC provides a kind of time-zone free or time-zone neutral time. The use of UTC time is recommended when a date and time's portability across computers is important. (For details and other best practices using dates and times, see [Coding best practices using DateTime in the .NET Framework](/previous-versions/dotnet/articles/ms973825(v=msdn.10)).) Converting individual time zones to UTC makes time comparisons easy. > [!NOTE] > You can also serialize a structure to unambiguously represent a single point in time. Because objects store a date and time value along with its offset from UTC, they always represent a particular point in time in relationship to UTC. @@ -65,7 +65,7 @@ The following code converts UTC to Central Standard Time. ## Converting UTC to local time -To convert UTC to local time, call the method of the object whose time you want to convert. The exact behavior of the method depends on the value of the object’s property, as the following table shows. +To convert UTC to local time, call the method of the object whose time you want to convert. The exact behavior of the method depends on the value of the object's property, as the following table shows. | `DateTime.Kind` | Conversion | | -------------------------- | ---------------------------------------------------------------------------------------- | diff --git a/docs/standard/datetime/create-time-zones-with-adjustment-rules.md b/docs/standard/datetime/create-time-zones-with-adjustment-rules.md index 66cca56db089d..f8079925932a8 100644 --- a/docs/standard/datetime/create-time-zones-with-adjustment-rules.md +++ b/docs/standard/datetime/create-time-zones-with-adjustment-rules.md @@ -6,9 +6,9 @@ dev_langs: - "csharp" - "vb" helpviewer_keywords: - - "time zones [.NET Framework], creating" - - "time zones [.NET Framework], and adjustment rules" - - "adjustment rule [.NET Framework]" + - "time zones [.NET], creating" + - "time zones [.NET], and adjustment rules" + - "adjustment rule [.NET]" ms.assetid: c52ef192-13a9-435f-8015-3b12eae8c47c --- # How to: Create time zones with adjustment rules diff --git a/docs/standard/datetime/create-time-zones-without-adjustment-rules.md b/docs/standard/datetime/create-time-zones-without-adjustment-rules.md index 23a05bcde335a..d3ceae1070255 100644 --- a/docs/standard/datetime/create-time-zones-without-adjustment-rules.md +++ b/docs/standard/datetime/create-time-zones-without-adjustment-rules.md @@ -6,9 +6,9 @@ dev_langs: - "csharp" - "vb" helpviewer_keywords: - - "time zones [.NET Framework], adjustment rule" - - "time zones [.NET Framework], creating" - - "adjustment rule [.NET Framework]" + - "time zones [.NET], adjustment rule" + - "time zones [.NET], creating" + - "adjustment rule [.NET]" ms.assetid: a6af8647-7893-4f29-95a9-d94c65a6e8dd --- # How to: Create time zones without adjustment rules diff --git a/docs/standard/datetime/enumerate-time-zones.md b/docs/standard/datetime/enumerate-time-zones.md index 29f0b3ef4f43c..7f396ce142fb1 100644 --- a/docs/standard/datetime/enumerate-time-zones.md +++ b/docs/standard/datetime/enumerate-time-zones.md @@ -6,8 +6,8 @@ dev_langs: - "csharp" - "vb" helpviewer_keywords: - - "time zones [.NET Framework], enumerating" - - "enumerating time zones [.NET Framework]" + - "time zones [.NET], enumerating" + - "enumerating time zones [.NET]" ms.assetid: bb7a42ab-6bd9-4c5c-b734-5546d51f8669 --- # How to: Enumerate time zones present on a computer diff --git a/docs/standard/datetime/finding-the-time-zones-on-local-system.md b/docs/standard/datetime/finding-the-time-zones-on-local-system.md index 3108a726881a0..de1ab672b3729 100644 --- a/docs/standard/datetime/finding-the-time-zones-on-local-system.md +++ b/docs/standard/datetime/finding-the-time-zones-on-local-system.md @@ -3,13 +3,13 @@ title: "Finding the time zones defined on a local system" ms.date: "04/10/2017" ms.technology: dotnet-standard helpviewer_keywords: - - "time zones [.NET Framework], local" - - "time zones [.NET Framework], finding local system time zones" - - "time zone identifiers [.NET Framework]" + - "time zones [.NET], local" + - "time zones [.NET], finding local system time zones" + - "time zone identifiers [.NET]" - "local time zone access" - - "time zones [.NET Framework], retrieving" + - "time zones [.NET], retrieving" - "UTC times, finding local system time zones" - - "time zones [.NET Framework], UTC" + - "time zones [.NET], UTC" ms.assetid: 3f63b1bc-9a4b-4bde-84ea-ab028a80d3e1 --- # Finding the time zones defined on a local system diff --git a/docs/standard/datetime/index.md b/docs/standard/datetime/index.md index e5e172648e9f3..023cce8ea9b75 100644 --- a/docs/standard/datetime/index.md +++ b/docs/standard/datetime/index.md @@ -3,11 +3,11 @@ title: "Dates, times, and time zones" ms.date: "04/10/2017" ms.technology: dotnet-standard helpviewer_keywords: - - "time zone objects [.NET Framework]" - - "date and time data [.NET Framework]" - - "time zones [.NET Framework]" - - "times [.NET Framework], time zones" - - "time [.NET Framework], time zones" + - "time zone objects [.NET]" + - "date and time data [.NET]" + - "time zones [.NET]" + - "times [.NET], time zones" + - "time [.NET], time zones" ms.assetid: 295c16e0-641b-4771-94b3-39c1ffa98c13 --- # Dates, times, and time zones diff --git a/docs/standard/datetime/instantiate-time-zone-info.md b/docs/standard/datetime/instantiate-time-zone-info.md index 3305f31d7f1c3..57b876695747b 100644 --- a/docs/standard/datetime/instantiate-time-zone-info.md +++ b/docs/standard/datetime/instantiate-time-zone-info.md @@ -7,7 +7,7 @@ dev_langs: - "vb" helpviewer_keywords: - "instantiating time zone objects" - - "time zone objects [.NET Framework], instantiation" + - "time zone objects [.NET], instantiation" ms.assetid: 8cb620e5-c6a6-4267-a52e-beeb73cd1a34 --- # How to: Instantiate a TimeZoneInfo object diff --git a/docs/standard/datetime/instantiating-a-datetimeoffset-object.md b/docs/standard/datetime/instantiating-a-datetimeoffset-object.md index 6b3e78402e9fe..f76439bf588f2 100644 --- a/docs/standard/datetime/instantiating-a-datetimeoffset-object.md +++ b/docs/standard/datetime/instantiating-a-datetimeoffset-object.md @@ -8,7 +8,7 @@ dev_langs: - "vb" helpviewer_keywords: - "instantiating time zone objects" - - "time zone objects [.NET Framework], instantiation" + - "time zone objects [.NET], instantiation" - "DateTimeOffset structure, converting to DateTime" - "DateTimeOffset structure, instantiating" ms.assetid: 9648375f-d368-4373-a976-3332ece00c0a diff --git a/docs/standard/datetime/let-users-resolve-ambiguous-times.md b/docs/standard/datetime/let-users-resolve-ambiguous-times.md index 1ba949fa73770..2207f5b942757 100644 --- a/docs/standard/datetime/let-users-resolve-ambiguous-times.md +++ b/docs/standard/datetime/let-users-resolve-ambiguous-times.md @@ -3,8 +3,8 @@ title: "How to: Let users resolve ambiguous times" ms.date: "04/10/2017" ms.technology: dotnet-standard helpviewer_keywords: - - "time zones [.NET Framework], ambiguous time" - - "ambiguous time [.NET Framework]" + - "time zones [.NET], ambiguous time" + - "ambiguous time [.NET]" ms.assetid: bca874ee-5b68-4654-8bbd-3711220ef332 --- # How to: Let users resolve ambiguous times diff --git a/docs/standard/datetime/performing-arithmetic-operations.md b/docs/standard/datetime/performing-arithmetic-operations.md index e38989bed86a6..297ea8e9b10fd 100644 --- a/docs/standard/datetime/performing-arithmetic-operations.md +++ b/docs/standard/datetime/performing-arithmetic-operations.md @@ -6,11 +6,11 @@ dev_langs: - "csharp" - "vb" helpviewer_keywords: - - "times [.NET Framework], arithmetic operations" - - "dates [.NET Framework], arithmetic operations" - - "time zones [.NET Framework], arithmetic operations" - - "arithmetic operations [.NET Framework], dates and times" - - "dates [.NET Framework], comparing" + - "times [.NET], arithmetic operations" + - "dates [.NET], arithmetic operations" + - "time zones [.NET], arithmetic operations" + - "arithmetic operations [.NET], dates and times" + - "dates [.NET], comparing" - "DateTime structure, arithmetic operations" - "DateTimeOffset structure, arithmetic operations" ms.assetid: 87c7ddf2-f15e-48af-8602-b3642237e6d0 diff --git a/docs/standard/datetime/resolve-ambiguous-times.md b/docs/standard/datetime/resolve-ambiguous-times.md index bc609b1ef0dd3..1dd9b561a9a2e 100644 --- a/docs/standard/datetime/resolve-ambiguous-times.md +++ b/docs/standard/datetime/resolve-ambiguous-times.md @@ -6,8 +6,8 @@ dev_langs: - "csharp" - "vb" helpviewer_keywords: - - "time zones [.NET Framework], ambiguous time" - - "ambiguous time [.NET Framework]" + - "time zones [.NET], ambiguous time" + - "ambiguous time [.NET]" ms.assetid: 2cf5fb25-492c-4875-9245-98cac8348e97 --- # How to: Resolve ambiguous times diff --git a/docs/standard/datetime/restore-time-zones-from-an-embedded-resource.md b/docs/standard/datetime/restore-time-zones-from-an-embedded-resource.md index de57662f4dbd1..31bb58e7ddb96 100644 --- a/docs/standard/datetime/restore-time-zones-from-an-embedded-resource.md +++ b/docs/standard/datetime/restore-time-zones-from-an-embedded-resource.md @@ -6,8 +6,8 @@ dev_langs: - "csharp" - "vb" helpviewer_keywords: - - "time zones [.NET Framework], deserializing" - - "time zones [.NET Framework], restoring" + - "time zones [.NET], deserializing" + - "time zones [.NET], restoring" ms.assetid: 6b7b4de9-da07-47e3-8f4c-823f81798ee7 --- # How to: Restore time zones from an embedded resource diff --git a/docs/standard/datetime/save-time-zones-to-an-embedded-resource.md b/docs/standard/datetime/save-time-zones-to-an-embedded-resource.md index 90655f7bee147..ec5dc1665a6e4 100644 --- a/docs/standard/datetime/save-time-zones-to-an-embedded-resource.md +++ b/docs/standard/datetime/save-time-zones-to-an-embedded-resource.md @@ -6,9 +6,9 @@ dev_langs: - "csharp" - "vb" helpviewer_keywords: - - "time zones [.NET Framework], saving" - - "time zone objects [.NET Framework], serializing" - - "time zone objects [.NET Framework], saving" + - "time zones [.NET], saving" + - "time zone objects [.NET], serializing" + - "time zone objects [.NET], saving" ms.assetid: 3c96d83a-a057-4496-abb0-8f4b12712558 --- # How to: Save time zones to an embedded resource diff --git a/docs/standard/datetime/saving-and-restoring-time-zones.md b/docs/standard/datetime/saving-and-restoring-time-zones.md index 50834f52616c7..2a6cb7a2cf3a2 100644 --- a/docs/standard/datetime/saving-and-restoring-time-zones.md +++ b/docs/standard/datetime/saving-and-restoring-time-zones.md @@ -7,15 +7,15 @@ dev_langs: - "vb" helpviewer_keywords: - "restoring time zones" - - "deserialization [.NET Framework], time zones" - - "serialization [.NET Framework], time zones" - - "time zone objects [.NET Framework], restoring" + - "deserialization [.NET], time zones" + - "serialization [.NET], time zones" + - "time zone objects [.NET], restoring" - "saving time zones" - - "time zone objects [.NET Framework], deserializing" - - "time zones [.NET Framework], saving" - - "time zones [.NET Framework], restoring" - - "time zone objects [.NET Framework], serializing" - - "time zone objects [.NET Framework], saving" + - "time zone objects [.NET], deserializing" + - "time zones [.NET], saving" + - "time zones [.NET], restoring" + - "time zone objects [.NET], serializing" + - "time zone objects [.NET], saving" ms.assetid: 4028b310-e7ce-49d4-a646-1e83bfaf6f9d --- # Saving and restoring time zones diff --git a/docs/standard/datetime/time-zone-overview.md b/docs/standard/datetime/time-zone-overview.md index cd8ee033708c8..0181e3e00f827 100644 --- a/docs/standard/datetime/time-zone-overview.md +++ b/docs/standard/datetime/time-zone-overview.md @@ -3,17 +3,17 @@ title: "Time zone overview" ms.date: "04/10/2017" ms.technology: dotnet-standard helpviewer_keywords: - - "time zones [.NET Framework], about time zones" - - "transition time [.NET Framework]" + - "time zones [.NET], about time zones" + - "transition time [.NET]" - "TimeZoneInfo class, about TimeZoneInfo class" - - "time zones [.NET Framework], creating" - - "invalid time [.NET Framework]" - - "fixed rule [.NET Framework]" - - "ambiguous time [.NET Framework]" - - "floating rule [.NET Framework]" - - "daylight saving time [.NET Framework]" - - "adjustment rule [.NET Framework]" - - "time zones [.NET Framework], terminology" + - "time zones [.NET], creating" + - "invalid time [.NET]" + - "fixed rule [.NET]" + - "ambiguous time [.NET]" + - "floating rule [.NET]" + - "daylight saving time [.NET]" + - "adjustment rule [.NET]" + - "time zones [.NET], terminology" ms.assetid: c4b7ed01-5e38-4959-a3b6-ef9765d6ccf1 --- # Time zone overview diff --git a/docs/standard/datetime/use-time-zones-in-arithmetic.md b/docs/standard/datetime/use-time-zones-in-arithmetic.md index 00862794cb14e..ff618bb522a94 100644 --- a/docs/standard/datetime/use-time-zones-in-arithmetic.md +++ b/docs/standard/datetime/use-time-zones-in-arithmetic.md @@ -6,9 +6,9 @@ dev_langs: - "csharp" - "vb" helpviewer_keywords: - - "time zones [.NET Framework], arithmetic operations" - - "arithmetic operations [.NET Framework], dates and times" - - "dates [.NET Framework], adding and subtracting" + - "time zones [.NET], arithmetic operations" + - "arithmetic operations [.NET], dates and times" + - "dates [.NET], adding and subtracting" ms.assetid: 83dd898d-1338-415d-8cd6-445377ab7871 --- # How to: Use time zones in date and time arithmetic diff --git a/docs/standard/events/how-to-handle-multiple-events-using-event-properties.md b/docs/standard/events/how-to-handle-multiple-events-using-event-properties.md index 8a98403946657..640a7115f181d 100644 --- a/docs/standard/events/how-to-handle-multiple-events-using-event-properties.md +++ b/docs/standard/events/how-to-handle-multiple-events-using-event-properties.md @@ -8,10 +8,10 @@ dev_langs: - "vb" - "cpp" helpviewer_keywords: - - "event properties [.NET Framework]" - - "multiple events [.NET Framework]" - - "event handling [.NET Framework], with multiple events" - - "events [.NET Framework], multiple" + - "event properties [.NET]" + - "multiple events [.NET]" + - "event handling [.NET], with multiple events" + - "events [.NET], multiple" ms.assetid: 30047cba-e2fd-41c6-b9ca-2ad7a49003db --- # How to: Handle Multiple Events Using Event Properties diff --git a/docs/standard/events/how-to-implement-a-provider.md b/docs/standard/events/how-to-implement-a-provider.md index 27568b4152bd7..ad879048daa37 100644 --- a/docs/standard/events/how-to-implement-a-provider.md +++ b/docs/standard/events/how-to-implement-a-provider.md @@ -6,9 +6,9 @@ dev_langs: - "csharp" - "vb" helpviewer_keywords: - - "observer design pattern [.NET Framework], implementing providers" - - "providers [.NET Framework], in observer design pattern" - - "observables [.NET Framework], in observer design pattern" + - "observer design pattern [.NET], implementing providers" + - "providers [.NET], in observer design pattern" + - "observables [.NET], in observer design pattern" ms.assetid: 790b5d8b-d546-40a6-beeb-151b574e5ee5 --- # How to: Implement a Provider diff --git a/docs/standard/events/how-to-implement-an-observer.md b/docs/standard/events/how-to-implement-an-observer.md index 37b4a94c53649..1978230fa1adf 100644 --- a/docs/standard/events/how-to-implement-an-observer.md +++ b/docs/standard/events/how-to-implement-an-observer.md @@ -7,8 +7,8 @@ dev_langs: - "csharp" - "vb" helpviewer_keywords: - - "observers [.NET Framework], observer design pattern" - - "observer design pattern [.NET Framework], implementing observers" + - "observers [.NET], observer design pattern" + - "observer design pattern [.NET], implementing observers" ms.assetid: 8ecfa9f5-b500-473d-bcf0-5652ffb1e53d --- # How to: Implement an Observer diff --git a/docs/standard/events/how-to-raise-and-consume-events.md b/docs/standard/events/how-to-raise-and-consume-events.md index 0e25c0ec6de50..fbaa8ee352ef1 100644 --- a/docs/standard/events/how-to-raise-and-consume-events.md +++ b/docs/standard/events/how-to-raise-and-consume-events.md @@ -8,9 +8,9 @@ dev_langs: - "vb" - "cpp" helpviewer_keywords: - - "events [.NET Framework], raising" + - "events [.NET], raising" - "raising events" - - "events [.NET Framework], samples" + - "events [.NET], samples" ms.assetid: 42afade7-3a02-4f2e-868b-95845f302f8f --- # How to: Raise and Consume Events diff --git a/docs/standard/events/index.md b/docs/standard/events/index.md index 971ec0b14b72a..8b91310d53230 100644 --- a/docs/standard/events/index.md +++ b/docs/standard/events/index.md @@ -9,11 +9,11 @@ dev_langs: helpviewer_keywords: - "delegate model for events" - "application development [.NET], events" - - "application development [.NET Framework], events" + - "application development [.NET], events" - "application development [.NET Core], events" - "events [.NET]" - "events [.NET Core]" - - "events [.NET Framework]" + - "events [.NET]" ms.assetid: b6f65241-e0ad-4590-a99f-200ce741bb1f --- # Handle and raising events diff --git a/docs/standard/events/observer-design-pattern-best-practices.md b/docs/standard/events/observer-design-pattern-best-practices.md index 9451ff40987db..ccda834cd35a2 100644 --- a/docs/standard/events/observer-design-pattern-best-practices.md +++ b/docs/standard/events/observer-design-pattern-best-practices.md @@ -3,12 +3,13 @@ title: "Observer Design Pattern Best Practices" ms.date: "03/30/2017" ms.technology: dotnet-standard helpviewer_keywords: - - "observer design pattern [.NET Framework], best practices" - - "best practices [.NET Framework], observer design pattern" + - "observer design pattern [.NET], best practices" + - "best practices [.NET], observer design pattern" ms.assetid: c834760f-ddd4-417f-abb7-a059679d5b8c --- # Observer Design Pattern Best Practices -In the .NET Framework, the observer design pattern is implemented as a set of interfaces. The interface represents the data provider, which is also responsible for providing an implementation that lets observers unsubscribe from notifications. The interface represents the observer. This topic describes the best practices that developers should follow when implementing the observer design pattern using these interfaces. + +In .NET, the observer design pattern is implemented as a set of interfaces. The interface represents the data provider, which is also responsible for providing an implementation that lets observers unsubscribe from notifications. The interface represents the observer. This topic describes the best practices that developers should follow when implementing the observer design pattern using these interfaces. ## Threading Typically, a provider implements the method by adding a particular observer to a subscriber list that is represented by some collection object, and it implements the method by removing a particular observer from the subscriber list. An observer can call these methods at any time. In addition, because the provider/observer contract does not specify who is responsible for unsubscribing after the callback method, the provider and observer may both try to remove the same member from the list. Because of this possibility, both the and methods should be thread-safe. Typically, this involves using a [concurrent collection](../parallel-programming/data-structures-for-parallel-programming.md) or a lock. Implementations that are not thread-safe should explicitly document that they are not. diff --git a/docs/standard/events/observer-design-pattern.md b/docs/standard/events/observer-design-pattern.md index 8f0a818fd8a77..1ec13c6d1dbb7 100644 --- a/docs/standard/events/observer-design-pattern.md +++ b/docs/standard/events/observer-design-pattern.md @@ -11,12 +11,12 @@ helpviewer_keywords: - "IObservable interface" - "IObserver interface" - "IObservable(Of T) interface" - - "observer design pattern [.NET Framework]" + - "observer design pattern [.NET]" ms.assetid: 3680171f-f522-453c-aa4a-54f755a78f88 --- # Observer Design Pattern -The observer design pattern enables a subscriber to register with and receive notifications from a provider. It is suitable for any scenario that requires push-based notification. The pattern defines a *provider* (also known as a *subject* or an *observable*) and zero, one, or more *observers*. Observers register with the provider, and whenever a predefined condition, event, or state change occurs, the provider automatically notifies all observers by calling one of their methods. In this method call, the provider can also provide current state information to observers. In the .NET Framework, the observer design pattern is applied by implementing the generic and interfaces. The generic type parameter represents the type that provides notification information. +The observer design pattern enables a subscriber to register with and receive notifications from a provider. It is suitable for any scenario that requires push-based notification. The pattern defines a *provider* (also known as a *subject* or an *observable*) and zero, one, or more *observers*. Observers register with the provider, and whenever a predefined condition, event, or state change occurs, the provider automatically notifies all observers by calling one of their methods. In this method call, the provider can also provide current state information to observers. In .NET, the observer design pattern is applied by implementing the generic and interfaces. The generic type parameter represents the type that provides notification information. ## Applying the Pattern diff --git a/docs/standard/garbage-collection/index.md b/docs/standard/garbage-collection/index.md index a42d6439c2930..2c6352d8590da 100644 --- a/docs/standard/garbage-collection/index.md +++ b/docs/standard/garbage-collection/index.md @@ -6,7 +6,7 @@ ms.technology: dotnet-standard helpviewer_keywords: - "memory, garbage collection" - "garbage collection, automatic memory management" - - "GC [.NET Framework]" + - "GC [.NET]" - "memory, allocating" - "common language runtime, garbage collection" - "garbage collector" diff --git a/docs/standard/garbage-collection/performance.md b/docs/standard/garbage-collection/performance.md index 4ba14df8f5d59..cf0dc58dbbc1f 100644 --- a/docs/standard/garbage-collection/performance.md +++ b/docs/standard/garbage-collection/performance.md @@ -18,7 +18,7 @@ The following sections describe the tools that are available for investigating m ### Memory Performance Counters -You can use performance counters to gather performance data. For instructions, see [Runtime Profiling](../../framework/debug-trace-profile/runtime-profiling.md). The .NET CLR Memory category of performance counters, as described in [Performance Counters in the .NET Framework](../../framework/debug-trace-profile/performance-counters.md), provides information about the garbage collector. +You can use performance counters to gather performance data. For instructions, see [Runtime Profiling](../../framework/debug-trace-profile/runtime-profiling.md). The .NET CLR Memory category of performance counters, as described in [Performance Counters in .NET](../../framework/debug-trace-profile/performance-counters.md), provides information about the garbage collector. ### Debugging with SOS @@ -28,7 +28,7 @@ To install WinDbg, install Debugging Tools for Windows from the [Download Debugg ### Garbage Collection ETW Events -Event tracing for Windows (ETW) is a tracing system that supplements the profiling and debugging support provided by the .NET Framework. Starting with the .NET Framework 4, [garbage collection ETW events](../../framework/performance/garbage-collection-etw-events.md) capture useful information for analyzing the managed heap from a statistical point of view. For example, the `GCStart_V1` event, which is raised when a garbage collection is about to occur, provides the following information: +Event tracing for Windows (ETW) is a tracing system that supplements the profiling and debugging support provided by .NET. Starting with .NET Framework 4, [garbage collection ETW events](../../framework/performance/garbage-collection-etw-events.md) capture useful information for analyzing the managed heap from a statistical point of view. For example, the `GCStart_V1` event, which is raised when a garbage collection is about to occur, provides the following information: - Which generation of objects is being collected. @@ -46,7 +46,7 @@ Profilers can provide comprehensive information. However, complex profilers can ### Application Domain Resource Monitoring -Starting with the .NET Framework 4, Application domain resource monitoring (ARM) enables hosts to monitor CPU and memory usage by application domain. For more information, see [Application Domain Resource Monitoring](app-domain-resource-monitoring.md). +Starting with .NET Framework 4, Application domain resource monitoring (ARM) enables hosts to monitor CPU and memory usage by application domain. For more information, see [Application Domain Resource Monitoring](app-domain-resource-monitoring.md). ## Troubleshooting Performance Issues @@ -176,7 +176,7 @@ Generation 0 is likely to have a larger number of objects on a 64-bit system, es CPU usage will be high during a garbage collection. If a significant amount of process time is spent in a garbage collection, the number of collections is too frequent or the collection is lasting too long. An increased allocation rate of objects on the managed heap causes garbage collection to occur more frequently. Decreasing the allocation rate reduces the frequency of garbage collections. -You can monitor allocation rates by using the `Allocated Bytes/second` performance counter. For more information, see [Performance Counters in the .NET Framework](../../framework/debug-trace-profile/performance-counters.md). +You can monitor allocation rates by using the `Allocated Bytes/second` performance counter. For more information, see [Performance Counters in .NET](../../framework/debug-trace-profile/performance-counters.md). The duration of a collection is primarily a factor of the number of objects that survive after allocation. The garbage collector must go through a large amount of memory if many objects remain to be collected. The work to compact the survivors is time-consuming. To determine how many objects were handled during a collection, set a breakpoint in the debugger at the end of a garbage collection for a specified generation. diff --git a/docs/standard/generics/collections.md b/docs/standard/generics/collections.md index e102b5305ca1b..f5ccb4a1655b0 100644 --- a/docs/standard/generics/collections.md +++ b/docs/standard/generics/collections.md @@ -39,7 +39,7 @@ ms.assetid: 5b646751-6ab7-465c-916c-b1a76aefa9f5 The generic structure provides a way to delimit a range of elements within a one-dimensional, zero-based array of any type. The generic type parameter is the type of the array's elements. - The generic delegate eliminates the need to declare a delegate type to handle events, if your event follows the event-handling pattern used by the .NET Framework. For example, suppose you have created a `MyEventArgs` class, derived from , to hold the data for your event. You can then declare the event as follows: + The generic delegate eliminates the need to declare a delegate type to handle events, if your event follows the event-handling pattern used by .NET. For example, suppose you have created a `MyEventArgs` class, derived from , to hold the data for your event. You can then declare the event as follows: [!code-cpp[Conceptual.Generics.Overview#7](../../../samples/snippets/cpp/VS_Snippets_CLR/conceptual.generics.overview/cpp/source2.cpp#7)] [!code-csharp[Conceptual.Generics.Overview#7](../../../samples/snippets/csharp/VS_Snippets_CLR/conceptual.generics.overview/cs/source2.cs#7)] diff --git a/docs/standard/generics/covariance-and-contravariance.md b/docs/standard/generics/covariance-and-contravariance.md index e17c05d186d08..c7af96472cd9c 100644 --- a/docs/standard/generics/covariance-and-contravariance.md +++ b/docs/standard/generics/covariance-and-contravariance.md @@ -13,26 +13,29 @@ helpviewer_keywords: - "generic type parameters" ms.assetid: 2678dc63-c7f9-4590-9ddc-0a4df684d42e --- -# Covariance and Contravariance in Generics -Covariance and contravariance are terms that refer to the ability to use a more derived type (more specific) or a less derived type (less specific) than originally specified. Generic type parameters support covariance and contravariance to provide greater flexibility in assigning and using generic types. When you are referring to a type system, covariance, contravariance, and invariance have the following definitions. The examples assume a base class named `Base` and a derived class named `Derived`. +# Covariance and contravariance in generics + +*Covariance* and *contravariance* are terms that refer to the ability to use a more derived type (more specific) or a less derived type (less specific) than originally specified. Generic type parameters support covariance and contravariance to provide greater flexibility in assigning and using generic types. + +When you're referring to a type system, covariance, contravariance, and invariance have the following definitions. The examples assume a base class named `Base` and a derived class named `Derived`. - `Covariance` Enables you to use a more derived type than originally specified. - You can assign an instance of `IEnumerable` (`IEnumerable(Of Derived)` in Visual Basic) to a variable of type `IEnumerable`. + You can assign an instance of `IEnumerable` to a variable of type `IEnumerable`. - `Contravariance` Enables you to use a more generic (less derived) type than originally specified. - You can assign an instance of `Action` (`Action(Of Base)` in Visual Basic) to a variable of type `Action`. + You can assign an instance of `Action` to a variable of type `Action`. - `Invariance` - Means that you can use only the type originally specified; so an invariant generic type parameter is neither covariant nor contravariant. + Means that you can use only the type originally specified. An invariant generic type parameter is neither covariant nor contravariant. - You cannot assign an instance of `List` (`List(Of Base)` in Visual Basic) to a variable of type `List` or vice versa. + You cannot assign an instance of `List` to a variable of type `List` or vice versa. Covariant type parameters enable you to make assignments that look much like ordinary [Polymorphism](../../csharp/programming-guide/classes-and-structs/polymorphism.md), as shown in the following code. @@ -46,13 +49,13 @@ Covariance and contravariance are terms that refer to the ability to use a more [!code-csharp[CoContraSimpleAction#1](../../../samples/snippets/csharp/VS_Snippets_CLR/cocontrasimpleaction/cs/example.cs#1)] [!code-vb[CoContraSimpleAction#1](../../../samples/snippets/visualbasic/VS_Snippets_CLR/cocontrasimpleaction/vb/example.vb#1)] - This seems backward, but it is type-safe code that compiles and runs. The lambda expression matches the delegate it is assigned to, so it defines a method that takes one parameter of type `Base` and that has no return value. The resulting delegate can be assigned to a variable of type `Action` because the type parameter `T` of the delegate is contravariant. The code is type-safe because `T` specifies a parameter type. When the delegate of type `Action` is invoked as if it were a delegate of type `Action`, its argument must be of type `Derived`. This argument can always be passed safely to the underlying method, because the method's parameter is of type `Base`. + This seems backward, but it is type-safe code that compiles and runs. The lambda expression matches the delegate it's assigned to, so it defines a method that takes one parameter of type `Base` and that has no return value. The resulting delegate can be assigned to a variable of type `Action` because the type parameter `T` of the delegate is contravariant. The code is type-safe because `T` specifies a parameter type. When the delegate of type `Action` is invoked as if it were a delegate of type `Action`, its argument must be of type `Derived`. This argument can always be passed safely to the underlying method, because the method's parameter is of type `Base`. In general, a covariant type parameter can be used as the return type of a delegate, and contravariant type parameters can be used as parameter types. For an interface, covariant type parameters can be used as the return types of the interface's methods, and contravariant type parameters can be used as the parameter types of the interface's methods. Covariance and contravariance are collectively referred to as *variance*. A generic type parameter that is not marked covariant or contravariant is referred to as *invariant*. A brief summary of facts about variance in the common language runtime: -- In the .NET Framework 4, variant type parameters are restricted to generic interface and generic delegate types. +- Variant type parameters are restricted to generic interface and generic delegate types. - A generic interface or generic delegate type can have both covariant and contravariant type parameters. @@ -60,17 +63,21 @@ Covariance and contravariance are terms that refer to the ability to use a more - Variance does not apply to delegate combination. That is, given two delegates of types `Action` and `Action` (`Action(Of Derived)` and `Action(Of Base)` in Visual Basic), you cannot combine the second delegate with the first although the result would be type safe. Variance allows the second delegate to be assigned to a variable of type `Action`, but delegates can combine only if their types match exactly. +- Starting in C# 9, covariant return types are supported. An overriding method can declare a more derived return type the method it overrides, and an overriding, read-only property can declare a more derived type. + -## Generic Interfaces with Covariant Type Parameters - Starting with the .NET Framework 4, several generic interfaces have covariant type parameters; for example: , , , and . All the type parameters of these interfaces are covariant, so the type parameters are used only for the return types of the members. +## Generic interfaces with covariant type parameters + +Several generic interfaces have covariant type parameters, for example, , , , and . All the type parameters of these interfaces are covariant, so the type parameters are used only for the return types of the members. The following example illustrates covariant type parameters. The example defines two types: `Base` has a static method named `PrintBases` that takes an `IEnumerable` (`IEnumerable(Of Base)` in Visual Basic) and prints the elements. `Derived` inherits from `Base`. The example creates an empty `List` (`List(Of Derived)` in Visual Basic) and demonstrates that this type can be passed to `PrintBases` and assigned to a variable of type `IEnumerable` without casting. implements , which has a single covariant type parameter. The covariant type parameter is the reason why an instance of `IEnumerable` can be used instead of `IEnumerable`. [!code-csharp[CoContravarianceInClrGenericI#1](../../../samples/snippets/csharp/VS_Snippets_CLR/cocontravarianceinclrgenerici/cs/example.cs#1)] [!code-vb[CoContravarianceInClrGenericI#1](../../../samples/snippets/visualbasic/VS_Snippets_CLR/cocontravarianceinclrgenerici/vb/example.vb#1)] -## Generic Interfaces with Contravariant Generic Type Parameters - Starting with the .NET Framework 4, several generic interfaces have contravariant type parameters; for example: , , and . These interfaces have only contravariant type parameters, so the type parameters are used only as parameter types in the members of the interfaces. +## Generic interfaces with contravariant type parameters + +Several generic interfaces have contravariant type parameters; for example: , , and . These interfaces have only contravariant type parameters, so the type parameters are used only as parameter types in the members of the interfaces. The following example illustrates contravariant type parameters. The example defines an abstract (`MustInherit` in Visual Basic) `Shape` class with an `Area` property. The example also defines a `ShapeAreaComparer` class that implements `IComparer` (`IComparer(Of Shape)` in Visual Basic). The implementation of the method is based on the value of the `Area` property, so `ShapeAreaComparer` can be used to sort `Shape` objects by area. @@ -81,8 +88,9 @@ Covariance and contravariance are terms that refer to the ability to use a more [!code-csharp[CoContravarianceInClrGenericI2#1](../../../samples/snippets/csharp/VS_Snippets_CLR/cocontravarianceinclrgenerici2/cs/example.cs#1)] [!code-vb[CoContravarianceInClrGenericI2#1](../../../samples/snippets/visualbasic/VS_Snippets_CLR/cocontravarianceinclrgenerici2/vb/example.vb#1)] -## Generic Delegates with Variant Type Parameters - In the .NET Framework 4, the `Func` generic delegates, such as , have covariant return types and contravariant parameter types. The `Action` generic delegates, such as , have contravariant parameter types. This means that the delegates can be assigned to variables that have more derived parameter types and (in the case of the `Func` generic delegates) less derived return types. +## Generic delegates with variant type parameters + +The `Func` generic delegates, such as , have covariant return types and contravariant parameter types. The `Action` generic delegates, such as , have contravariant parameter types. This means that the delegates can be assigned to variables that have more derived parameter types and (in the case of the `Func` generic delegates) less derived return types. > [!NOTE] > The last generic type parameter of the `Func` generic delegates specifies the type of the return value in the delegate signature. It is covariant (`out` keyword), whereas the other generic type parameters are contravariant (`in` keyword). @@ -107,7 +115,8 @@ Covariance and contravariance are terms that refer to the ability to use a more [!code-csharp[CoContravarianceDelegates#5](../../../samples/snippets/csharp/VS_Snippets_CLR/cocontravariancedelegates/cs/example.cs#5)] [!code-vb[CoContravarianceDelegates#5](../../../samples/snippets/visualbasic/VS_Snippets_CLR/cocontravariancedelegates/vb/example.vb#5)] -### Variance in Generic and Non-Generic Delegates +### Variance in non-generic delegates + In the preceding code, the signature of `MyMethod` exactly matches the signature of the constructed generic delegate: `Func` (`Func(Of Base, Derived)` in Visual Basic). The example shows that this generic delegate can be stored in variables or method parameters that have more derived parameter types and less derived return types, as long as all the delegate types are constructed from the generic delegate type . This is an important point. The effects of covariance and contravariance in the type parameters of generic delegates are similar to the effects of covariance and contravariance in ordinary delegate binding (see [Variance in Delegates (C#)](../../csharp/programming-guide/concepts/covariance-contravariance/variance-in-delegates.md) and [Variance in Delegates (Visual Basic)](../../visual-basic/programming-guide/concepts/covariance-contravariance/variance-in-delegates.md)). However, variance in delegate binding works with all delegate types, not just with generic delegate types that have variant type parameters. Furthermore, variance in delegate binding enables a method to be bound to any delegate that has more restrictive parameter types and a less restrictive return type, whereas the assignment of generic delegates works only if both delegate types are constructed from the same generic type definition. @@ -117,27 +126,26 @@ Covariance and contravariance are terms that refer to the ability to use a more [!code-csharp[CoContravarianceDelegatesGenRelaxed#1](../../../samples/snippets/csharp/VS_Snippets_CLR/cocontravariancedelegatesgenrelaxed/cs/example.cs#1)] [!code-vb[CoContravarianceDelegatesGenRelaxed#1](../../../samples/snippets/visualbasic/VS_Snippets_CLR/cocontravariancedelegatesgenrelaxed/vb/example.vb#1)] -## Defining Variant Generic Interfaces and Delegates - Starting with the .NET Framework 4, Visual Basic and C# have keywords that enable you to mark the generic type parameters of interfaces and delegates as covariant or contravariant. - -> [!NOTE] -> Starting with the .NET Framework version 2.0, the common language runtime supports variance annotations on generic type parameters. Prior to the .NET Framework 4, the only way to define a generic class that has these annotations is to use Microsoft intermediate language (MSIL), either by compiling the class with [Ilasm.exe (IL Assembler)](../../framework/tools/ilasm-exe-il-assembler.md) or by emitting it in a dynamic assembly. +## Define variant generic interfaces and delegates + +Visual Basic and C# have keywords that enable you to mark the generic type parameters of interfaces and delegates as covariant or contravariant. - A covariant type parameter is marked with the `out` keyword (`Out` keyword in Visual Basic, `+` for the [MSIL Assembler](../../framework/tools/ilasm-exe-il-assembler.md)). You can use a covariant type parameter as the return value of a method that belongs to an interface, or as the return type of a delegate. You cannot use a covariant type parameter as a generic type constraint for interface methods. + A covariant type parameter is marked with the `out` keyword (`Out` keyword in Visual Basic). You can use a covariant type parameter as the return value of a method that belongs to an interface, or as the return type of a delegate. You cannot use a covariant type parameter as a generic type constraint for interface methods. > [!NOTE] > If a method of an interface has a parameter that is a generic delegate type, a covariant type parameter of the interface type can be used to specify a contravariant type parameter of the delegate type. - A contravariant type parameter is marked with the `in` keyword (`In` keyword in Visual Basic, `-` for the [MSIL Assembler](../../framework/tools/ilasm-exe-il-assembler.md)). You can use a contravariant type parameter as the type of a parameter of a method that belongs to an interface, or as the type of a parameter of a delegate. You can use a contravariant type parameter as a generic type constraint for an interface method. + A contravariant type parameter is marked with the `in` keyword (`In` keyword in Visual Basic). You can use a contravariant type parameter as the type of a parameter of a method that belongs to an interface, or as the type of a parameter of a delegate. You can use a contravariant type parameter as a generic type constraint for an interface method. Only interface types and delegate types can have variant type parameters. An interface or delegate type can have both covariant and contravariant type parameters. - Visual Basic and C# do not allow you to violate the rules for using covariant and contravariant type parameters, or to add covariance and contravariance annotations to the type parameters of types other than interfaces and delegates. The [MSIL Assembler](../../framework/tools/ilasm-exe-il-assembler.md) does not perform such checks, but a is thrown if you try to load a type that violates the rules. + Visual Basic and C# do not allow you to violate the rules for using covariant and contravariant type parameters, or to add covariance and contravariance annotations to the type parameters of types other than interfaces and delegates. For information and example code, see [Variance in Generic Interfaces (C#)](../../csharp/programming-guide/concepts/covariance-contravariance/variance-in-generic-interfaces.md) and [Variance in Generic Interfaces (Visual Basic)](../../visual-basic/programming-guide/concepts/covariance-contravariance/variance-in-generic-interfaces.md). -## List of Variant Generic Interface and Delegate Types - In the .NET Framework 4, the following interface and delegate types have covariant and/or contravariant type parameters. +## List of types + +The following interface and delegate types have covariant and/or contravariant type parameters. |Type|Covariant type parameters|Contravariant type parameters| |----------|-------------------------------|-----------------------------------| diff --git a/docs/standard/generics/delegates-for-manipulating-arrays-and-lists.md b/docs/standard/generics/delegates-for-manipulating-arrays-and-lists.md index b488cf92caa2a..8a55b1285fcf7 100644 --- a/docs/standard/generics/delegates-for-manipulating-arrays-and-lists.md +++ b/docs/standard/generics/delegates-for-manipulating-arrays-and-lists.md @@ -3,12 +3,12 @@ title: "Generic Delegates for Manipulating Arrays and Lists" ms.date: "03/30/2017" ms.technology: dotnet-standard helpviewer_keywords: - - "delegates [.NET Framework], generic delegates" + - "delegates [.NET], generic delegates" - "chaining delegates" - - "arrays [.NET Framework], generic delegates" - - "generic delegates [.NET Framework]" - - "lists [.NET Framework], generic delegates" - - "generics [.NET Framework], delegates" + - "arrays [.NET], generic delegates" + - "generic delegates [.NET]" + - "lists [.NET], generic delegates" + - "generics [.NET], delegates" ms.assetid: 416be383-cc61-4102-9b1b-88b51adb963e --- # Generic Delegates for Manipulating Arrays and Lists @@ -38,6 +38,6 @@ This topic provides an overview of generic delegates for conversions, search pre - - - [Generics](index.md) -- [Generic Collections in the .NET Framework](collections.md) +- [Generic Collections in the .NET](collections.md) - [Generic Interfaces](interfaces.md) - [Covariance and Contravariance](covariance-and-contravariance.md) diff --git a/docs/standard/generics/index.md b/docs/standard/generics/index.md index 3aa88e1dcad69..75f499e289b98 100644 --- a/docs/standard/generics/index.md +++ b/docs/standard/generics/index.md @@ -9,21 +9,21 @@ dev_langs: - "cpp" helpviewer_keywords: - "generic methods, type inference" - - "generics [.NET Framework], collections" - - "generic interfaces [.NET Framework]" + - "generics [.NET], collections" + - "generic interfaces [.NET]" - "constructed generic types" - "nested generic types" - "generic type definitions" - - "generic classes [.NET Framework]" - - "generics [.NET Framework], interfaces" - - "generics [.NET Framework], about" - - "generics [.NET Framework]" - - "generic collections [.NET Framework]" - - "generic delegates [.NET Framework]" + - "generic classes [.NET]" + - "generics [.NET], interfaces" + - "generics [.NET], about" + - "generics [.NET]" + - "generic collections [.NET]" + - "generic delegates [.NET]" - "generic type arguments" - - "generics [.NET Framework], delegates" - - "generics [.NET Framework], features" - - "constraints [.NET Framework]" + - "generics [.NET], delegates" + - "generics [.NET], features" + - "constraints [.NET]" - "generic types" - "generic type parameters" ms.assetid: 2994d786-c5c7-4666-ab23-4c83129fe39c @@ -93,7 +93,7 @@ Generics let you tailor a method, class, structure, or interface to the precise The following are some limitations of generics: -- Generic types can be derived from most base classes, such as (and constraints can be used to require that generic type parameters derive from base classes like ). However, the .NET Framework does not support context-bound generic types. A generic type can be derived from , but trying to create an instance of that type causes a . +- Generic types can be derived from most base classes, such as (and constraints can be used to require that generic type parameters derive from base classes like ). However, .NET does not support context-bound generic types. A generic type can be derived from , but trying to create an instance of that type causes a . - Enumerations cannot have generic type parameters. An enumeration can be generic only incidentally (for example, because it is nested in a generic type that is defined using Visual Basic, C#, or C++). For more information, see "Enumerations" in [Common Type System](../base-types/common-type-system.md). diff --git a/docs/standard/generics/interfaces.md b/docs/standard/generics/interfaces.md index 6c6731f1d2325..b327ff028fb60 100644 --- a/docs/standard/generics/interfaces.md +++ b/docs/standard/generics/interfaces.md @@ -3,34 +3,34 @@ title: "Generic Interfaces" ms.date: "03/30/2017" ms.technology: dotnet-standard helpviewer_keywords: - - "generic interfaces [.NET Framework]" - - "equality comparisons [.NET Framework]" - - "generics [.NET Framework], interfaces" - - "ordering comparisons [.NET Framework]" + - "generic interfaces [.NET]" + - "equality comparisons [.NET]" + - "generics [.NET], interfaces" + - "ordering comparisons [.NET]" ms.assetid: 88bf5b04-d371-4edb-ba38-01ec7cabaacf --- -# Generic Interfaces -This topic provides an overview of generic interfaces that provide common functionality across families of generic types. +# Generic interfaces + +This article provides an overview of generic interfaces that provide common functionality across families of generic types. -## Generic Interfaces - Generic interfaces provide type-safe counterparts to nongeneric interfaces for ordering and equality comparisons and for functionality that is shared by generic collection types. +Generic interfaces provide type-safe counterparts to nongeneric interfaces for ordering and equality comparisons and for functionality that is shared by generic collection types. > [!NOTE] -> Starting with the .NET Framework 4, the type parameters of several generic interfaces are marked covariant or contravariant, providing greater flexibility in assigning and using types that implement these interfaces. See [Covariance and Contravariance](covariance-and-contravariance.md). +> The type parameters of several generic interfaces are marked covariant or contravariant, providing greater flexibility in assigning and using types that implement these interfaces. See [Covariance and Contravariance](covariance-and-contravariance.md). -### Equality and Ordering Comparisons +## Equality and Ordering Comparisons In the namespace, the and generic interfaces, like their nongeneric counterparts, define methods for ordering comparisons and equality comparisons, respectively. Types implement these interfaces to provide the ability to perform such comparisons. In the namespace, the and generic interfaces offer a way to define an ordering or equality comparison for types that do not implement the or generic interface, and they provide a way to redefine those relationships for types that do. These interfaces are used by methods and constructors of many of the generic collection classes. For example, you can pass a generic object to the constructor of the class to specify a sort order for a type that does not implement generic . There are overloads of the generic static method and the instance method for sorting arrays and lists using generic implementations. The and generic classes provide base classes for implementations of the and generic interfaces, and also provide default ordering and equality comparisons through their respective and properties. -### Collection Functionality +## Collection Functionality The generic interface is the basic interface for generic collection types. It provides basic functionality for adding, removing, copying, and enumerating elements. inherits from both generic and nongeneric . The generic interface extends the generic interface with methods for indexed retrieval. - The generic interface extends the generic interface with methods for keyed retrieval. Generic dictionary types in the .NET Framework base class library also implement the nongeneric interface. + The generic interface extends the generic interface with methods for keyed retrieval. Generic dictionary types in the .NET base class library also implement the nongeneric interface. The generic interface provides a generic enumerator structure. The generic interface implemented by generic enumerators inherits the nongeneric interface; the and members, which do not depend on the type parameter `T`, appear only on the nongeneric interface. This means that any consumer of the nongeneric interface can also consume the generic interface. @@ -39,6 +39,6 @@ This topic provides an overview of generic interfaces that provide common functi - - - [Generics](index.md) -- [Generic Collections in the .NET Framework](collections.md) +- [Generic Collections in .NET](collections.md) - [Generic Delegates for Manipulating Arrays and Lists](delegates-for-manipulating-arrays-and-lists.md) - [Covariance and Contravariance](covariance-and-contravariance.md) diff --git a/docs/standard/globalization-localization/best-practices-for-developing-world-ready-apps.md b/docs/standard/globalization-localization/best-practices-for-developing-world-ready-apps.md index 1c20e14a6ea61..54ec379ca1503 100644 --- a/docs/standard/globalization-localization/best-practices-for-developing-world-ready-apps.md +++ b/docs/standard/globalization-localization/best-practices-for-developing-world-ready-apps.md @@ -5,8 +5,8 @@ ms.technology: dotnet-standard helpviewer_keywords: - "global applications, best practices" - "world-ready applications, best practices" - - "globalization [.NET Framework], best practices" - - "international applications [.NET Framework], best practices" + - "globalization [.NET], best practices" + - "international applications [.NET], best practices" ms.assetid: f08169c7-aad8-4ec3-9a21-9ebd3b89986c --- # Best practices for developing world-ready applications diff --git a/docs/standard/globalization-localization/culture-insensitive-string-operations.md b/docs/standard/globalization-localization/culture-insensitive-string-operations.md index bb37a6d8c37fb..79022ae26cd48 100644 --- a/docs/standard/globalization-localization/culture-insensitive-string-operations.md +++ b/docs/standard/globalization-localization/culture-insensitive-string-operations.md @@ -5,9 +5,9 @@ ms.technology: dotnet-standard helpviewer_keywords: - "culture, culture-insensitive string operations" - "case-sensitive comparisons" - - "globalization [.NET Framework], culture-insensitive string operations" - - "strings [.NET Framework], culture-insensitive string operations" - - "localization [.NET Framework], culture-insensitive string operations" + - "globalization [.NET], culture-insensitive string operations" + - "strings [.NET], culture-insensitive string operations" + - "localization [.NET], culture-insensitive string operations" - "world-ready applications, culture-insensitive string operations" - "culture-sensitive string operations" - "culture-insensitive string operations" @@ -17,13 +17,13 @@ ms.assetid: e6e2bb94-a95d-44e2-b68c-cfdd1db77784 Culture-sensitive string operations can be an advantage if you are creating applications designed to display results to users on a per-culture basis. By default, culture-sensitive methods obtain the culture to use from the property for the current thread. -Note that culture-sensitive string operations are not always the desired behavior. Using culture-sensitive operations when results should be independent of culture can cause application code to fail on cultures with custom case mappings and sorting rules. For an example, see the ["String Comparisons that Use the Current Culture"](../base-types/best-practices-strings.md#string-comparisons-that-use-the-current-culture) section in the [Best Practices for Using Strings](../base-types/best-practices-strings.md) article. +Sometimes, culture-sensitive string operations are not the desired behavior. Using culture-sensitive operations when results should be independent of culture can cause application code to fail on cultures with custom case mappings and sorting rules. For an example, see the ["String Comparisons that Use the Current Culture"](../base-types/best-practices-strings.md#string-comparisons-that-use-the-current-culture) section in the [Best Practices for Using Strings](../base-types/best-practices-strings.md) article. Whether string operations should be culture-sensitive or culture-insensitive depends on how your application uses the results. String operations that display results to the user should typically be culture-sensitive. For example, if an application displays a sorted list of localized strings in a list box, the application should perform a culture-sensitive sort. Results of string operations that are used internally should typically be culture-insensitive. In general, if the application is working with file names, persistence formats, or symbolic information that is not displayed to the user, results of string operations should not vary by culture. For example, if an application compares a string to determine whether it is a recognized XML tag, the comparison should not be culture-sensitive. In addition, if a security decision is based on the result of a string comparison or case change operation, the operation should be culture-insensitive to ensure that the result is not affected by the value of . -Whether or not you are developing an application that includes code to handle localization and globalization issues, you should be aware of the .NET Framework methods that retrieve culture-sensitive results by default. The purpose of this topic is to illustrate the correct way for your applications to use these methods to obtain culture-insensitive results. +Whether or not you're developing an application that includes code to handle localization and globalization issues, you should be aware of the .NET methods that retrieve culture-sensitive results by default. ## See also diff --git a/docs/standard/globalization-localization/globalization-icu.md b/docs/standard/globalization-localization/globalization-icu.md index b53d98e641b8b..5c6a769c51fb2 100644 --- a/docs/standard/globalization-localization/globalization-icu.md +++ b/docs/standard/globalization-localization/globalization-icu.md @@ -3,11 +3,11 @@ title: "Globalization and ICU" ms.date: "05/21/2020" ms.technology: dotnet-standard helpviewer_keywords: - - "globalization [.NET Framework], about globalization" + - "globalization [.NET], about globalization" - "global applications, globalization" - - "international applications [.NET Framework], globalization" + - "international applications [.NET], globalization" - "world-ready applications, globalization" - - "application development [.NET Framework], globalization" + - "application development [.NET], globalization" - "culture, globalization" - "icu, icu on windows, ms-icu" --- diff --git a/docs/standard/globalization-localization/globalization.md b/docs/standard/globalization-localization/globalization.md index 7890e8e920b89..2c79692fedac1 100644 --- a/docs/standard/globalization-localization/globalization.md +++ b/docs/standard/globalization-localization/globalization.md @@ -6,11 +6,11 @@ dev_langs: - "csharp" - "vb" helpviewer_keywords: - - "globalization [.NET Framework], about globalization" + - "globalization [.NET], about globalization" - "global applications, globalization" - - "international applications [.NET Framework], globalization" + - "international applications [.NET], globalization" - "world-ready applications, globalization" - - "application development [.NET Framework], globalization" + - "application development [.NET], globalization" - "culture, globalization" ms.assetid: 4e919934-6b19-42f2-b770-275a4fae87c9 --- @@ -96,7 +96,7 @@ Typically, ordered strings that are to be displayed in the user interface should Culture-sensitive string comparison is defined by the object, which is returned by each culture's property. Culture-sensitive string comparisons that use the method overloads also use the object. -.NET uses tables to perform culture-sensitive sorts on string data. The content of these tables, which contain data on sort weights and string normalization, is determined by the version of the Unicode standard implemented by a particular version of .NET. The following table lists the versions of Unicode implemented by the specified versions of the .NET Framework and by .NET Core. Note that this list of supported Unicode versions applies to character comparison and sorting only; it does not apply to classification of Unicode characters by category. For more information, see the "Strings and The Unicode Standard" section in the article. +.NET uses tables to perform culture-sensitive sorts on string data. The content of these tables, which contain data on sort weights and string normalization, is determined by the version of the Unicode standard implemented by a particular version of .NET. The following table lists the versions of Unicode implemented by the specified versions of .NET. This list of supported Unicode versions applies to character comparison and sorting only; it does not apply to classification of Unicode characters by category. For more information, see the "Strings and The Unicode Standard" section in the article. |.NET Framework version|Operating system|Unicode version| |----------------------------|----------------------|---------------------| @@ -106,9 +106,9 @@ Culture-sensitive string comparison is defined by the class to determine when your serialized data needs to be sorted so that it is consistent with .NET and the operating system's sort order. For an example, see the class topic. +Starting with .NET Framework 4.5 and in all versions of .NET Core and .NET 5+, string comparison and sorting depends on the operating system. .NET Framework 4.5 and later running on Windows 7 retrieves data from its own tables that implement Unicode 5.0. .NET Framework 4.5 and later running on Windows 8 and later retrieves data from operating system tables that implement Unicode 6.3. On .NET Core and .NET 5+, the supported version of Unicode depends on the underlying operating system. If you serialize culture-sensitive sorted data, you can use the class to determine when your serialized data needs to be sorted so that it is consistent with .NET and the operating system's sort order. For an example, see the class topic. If your app performs extensive culture-specific sorts of string data, you can work with the class to compare strings. A sort key reflects the culture-specific sort weights, including the alphabetic, case, and diacritic weights of a particular string. Because comparisons using sort keys are binary, they are faster than comparisons that use a object either implicitly or explicitly. You create a culture-specific sort key for a particular string by passing the string to the method. diff --git a/docs/standard/globalization-localization/localizability-review.md b/docs/standard/globalization-localization/localizability-review.md index 92d1c918cd3b9..f11e9f117a97c 100644 --- a/docs/standard/globalization-localization/localizability-review.md +++ b/docs/standard/globalization-localization/localizability-review.md @@ -7,12 +7,12 @@ dev_langs: - "vb" helpviewer_keywords: - "world-ready applications, localizability" - - "application development [.NET Framework], localization" - - "localizability [.NET Framework]" - - "international applications [.NET Framework], localizability" - - "globalization [.NET Framework], localizability" + - "application development [.NET], localization" + - "localizability [.NET]" + - "international applications [.NET], localizability" + - "globalization [.NET], localizability" - "culture, localizability" - - "localization [.NET Framework], localizability" + - "localization [.NET], localizability" - "global applications, localizability" - "localizing resources" ms.assetid: 3aee2fbb-de47-4e37-8fe4-ddebb9719247 diff --git a/docs/standard/globalization-localization/localization.md b/docs/standard/globalization-localization/localization.md index 2558c3619b8bc..138834cb12892 100644 --- a/docs/standard/globalization-localization/localization.md +++ b/docs/standard/globalization-localization/localization.md @@ -4,14 +4,14 @@ ms.date: "03/30/2017" ms.technology: dotnet-standard helpviewer_keywords: - "culture, localization" - - "application development [.NET Framework], localization" - - "globalization [.NET Framework], localization" + - "application development [.NET], localization" + - "globalization [.NET], localization" - "code blocks" - - "international applications [.NET Framework], localization" + - "international applications [.NET], localization" - "global applications, localization" - "world-ready applications, localization" - "user interface blocks" - - "localization [.NET Framework], about localization" + - "localization [.NET], about localization" - "localizing resources" ms.assetid: 49d520d7-92d7-44ee-bb24-8b615db1d41b --- diff --git a/docs/standard/globalization-localization/performing-culture-insensitive-string-comparisons.md b/docs/standard/globalization-localization/performing-culture-insensitive-string-comparisons.md index 79ee81907e9d3..605c0f7ca69c8 100644 --- a/docs/standard/globalization-localization/performing-culture-insensitive-string-comparisons.md +++ b/docs/standard/globalization-localization/performing-culture-insensitive-string-comparisons.md @@ -8,8 +8,8 @@ dev_langs: helpviewer_keywords: - "String.CompareTo method" - "String.Compare method" - - "string comparison [.NET Framework], culture-insensitive" - - "strings [.NET Framework], comparing" + - "string comparison [.NET], culture-insensitive" + - "strings [.NET], comparing" - "culture-insensitive string operations, comparisons" - "culture parameter" ms.assetid: abae50ef-32f7-4a50-a540-fd256fd1aed0 @@ -24,7 +24,7 @@ By default, the met The culture-insensitive string comparisons supported by the method are either linguistic (based on the sorting conventions of the invariant culture) or non-linguistic (based on the ordinal value of the characters in the string). Most culture-insensitive string comparisons are non-linguistic. For these comparisons, specify the or enumeration value as the `comparisonType` parameter. For example, if a security decision (such as a user name or password comparison) is based on the result of a string comparison, the operation should be culture-insensitive and non-linguistic to ensure that the result is not affected by the conventions of a particular culture or language. - Use culture-insensitive linguistic string comparison if you want to handle linguistically relevant strings from multiple cultures in a consistent way. For example, if your application displays words that use multiple character sets in a list box, you might want to display words in the same order regardless of the current culture. For culture-insensitive linguistic comparisons, the .NET Framework defines an invariant culture that is based on the linguistic conventions of English. To perform a culture-insensitive linguistic comparison, specify or as the `comparisonType` parameter. + Use culture-insensitive linguistic string comparison if you want to handle linguistically relevant strings from multiple cultures in a consistent way. For example, if your application displays words that use multiple character sets in a list box, you might want to display words in the same order regardless of the current culture. For culture-insensitive linguistic comparisons, .NET defines an invariant culture that is based on the linguistic conventions of English. To perform a culture-insensitive linguistic comparison, specify or as the `comparisonType` parameter. The following example performs two culture-insensitive, non-linguistic string comparisons. The first is case-sensitive, but the second is not. diff --git a/docs/standard/globalization-localization/performing-culture-insensitive-string-operations-in-arrays.md b/docs/standard/globalization-localization/performing-culture-insensitive-string-operations-in-arrays.md index eac5f09795fd2..093b970ad59dd 100644 --- a/docs/standard/globalization-localization/performing-culture-insensitive-string-operations-in-arrays.md +++ b/docs/standard/globalization-localization/performing-culture-insensitive-string-operations-in-arrays.md @@ -4,7 +4,7 @@ ms.date: "03/30/2017" ms.technology: dotnet-standard helpviewer_keywords: - "culture-insensitive string operations, in arrays" - - "arrays [.NET Framework], culture-insensitive string operations" + - "arrays [.NET], culture-insensitive string operations" - "comparer parameter" ms.assetid: f12922e1-6234-4165-8896-63f0653ab478 --- diff --git a/docs/standard/globalization-localization/performing-culture-insensitive-string-operations-in-collections.md b/docs/standard/globalization-localization/performing-culture-insensitive-string-operations-in-collections.md index fe319d5a34511..875b94fe24c8f 100644 --- a/docs/standard/globalization-localization/performing-culture-insensitive-string-operations-in-collections.md +++ b/docs/standard/globalization-localization/performing-culture-insensitive-string-operations-in-collections.md @@ -9,7 +9,7 @@ helpviewer_keywords: - "CaseInsensitiveComparer class, using" - "CollectionsUtil.CreateCaseInsensitiveHashtable method" - "culture-insensitive string operations, collections" - - "collections [.NET Framework], culture-insensitive string operations" + - "collections [.NET], culture-insensitive string operations" - "CaseInsensitiveHashCodeProvider class, using" - "ArrayList.Sort method" - "SortedList class, culture-insensitive string operations" diff --git a/docs/standard/globalization-localization/performing-culture-insensitive-string-operations.md b/docs/standard/globalization-localization/performing-culture-insensitive-string-operations.md index 51a36933b622f..d822eef304548 100644 --- a/docs/standard/globalization-localization/performing-culture-insensitive-string-operations.md +++ b/docs/standard/globalization-localization/performing-culture-insensitive-string-operations.md @@ -13,9 +13,10 @@ helpviewer_keywords: ms.assetid: 579ef891-1f83-4c63-9ebd-2f40406b5b91 --- # Performing culture-insensitive string operations -Most .NET Framework methods that perform culture-sensitive string operations by default provide method overloads that allow you to explicitly specify the culture to use by passing a parameter. These overloads allow you to eliminate cultural variations in case mappings and sorting rules and guarantee culture-insensitive results. + +Most .NET methods that perform culture-sensitive string operations by default provide method overloads that allow you to explicitly specify the culture to use by passing a parameter. These overloads allow you to eliminate cultural variations in case mappings and sorting rules and guarantee culture-insensitive results. - This section provides the following topics to demonstrate how to perform culture-insensitive string operations using .NET Framework methods that are culture-sensitive by default. + This section provides the following articles to demonstrate how to perform culture-insensitive string operations using .NET methods that are culture-sensitive by default. ## In this section [Performing Culture-Insensitive String Comparisons](performing-culture-insensitive-string-comparisons.md)