Skip to content

Commit 13c5547

Browse files
Object.xml -- updating for Try .NET (#3346)
* updating for Try .NET * updating per review comments * updating per review comments * fixes Co-authored-by: Maira Wenzel <[email protected]>
1 parent a2a60d5 commit 13c5547

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

xml/System/Object.xml

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,15 @@
138138
</AssemblyInfo>
139139
<Docs>
140140
<summary>Determines whether two object instances are equal.</summary>
141+
<remarks>
142+
<format type="text/markdown"><![CDATA[
143+
144+
## Remarks
145+
146+
[!INCLUDE[interactive-note](~/includes/csharp-interactive-note-some.md)]
147+
148+
]]></format>
149+
</remarks>
141150
</Docs>
142151
</MemberGroup>
143152
<Member MemberName="Equals">
@@ -191,7 +200,7 @@
191200
192201
## Remarks
193202
The type of comparison between the current instance and the `obj` parameter depends on whether the current instance is a reference type or a value type.
194-
203+
195204
- If the current instance is a reference type, the <xref:System.Object.Equals%28System.Object%29> method tests for reference equality, and a call to the <xref:System.Object.Equals%28System.Object%29> method is equivalent to a call to the <xref:System.Object.ReferenceEquals%2A> method. Reference equality means that the object variables that are compared refer to the same object. The following example illustrates the result of such a comparison. It defines a `Person` class, which is a reference type, and calls the `Person` class constructor to instantiate two new `Person` objects, `person1a` and `person2`, which have the same value. It also assigns `person1a` to another object variable, `person1b`. As the output from the example shows, `person1a` and `person1b` are equal because they reference the same object. However, `person1a` and `person2` are not equal, although they have the same value.
196205
197206
[!code-csharp[System.Object.Equals#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.object.equals/cs/equals_ref.cs#2)]
@@ -201,7 +210,7 @@
201210
202211
- The two objects are of the same type. As the following example shows, a <xref:System.Byte> object that has a value of 12 does not equal an <xref:System.Int32> object that has a value of 12, because the two objects have different run-time types.
203212
204-
[!code-csharp[System.Object.Equals#3](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.object.equals/cs/equals_val1.cs#3)]
213+
[!code-csharp-interactive[System.Object.Equals#3](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.object.equals/cs/equals_val1.cs#3)]
205214
[!code-vb[System.Object.Equals#3](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.object.equals/vb/equals_val1.vb#3)]
206215
207216
- The values of the public and private fields of the two objects are equal. The following example tests for value equality. It defines a `Person` structure, which is a value type, and calls the `Person` class constructor to instantiate two new `Person` objects, `person1` and `person2`, which have the same value. As the output from the example shows, although the two object variables refer to different objects, `person1` and `person2` are equal because they have the same value for the private `personName` field.
@@ -769,6 +778,8 @@ and the <xref:System.IDisposable> interface. The <xref:System.IDisposable.Dispos
769778
770779
For two objects `x` and `y` that have identical runtime types, `Object.ReferenceEquals(x.GetType(),y.GetType())` returns `true`. The following example uses the <xref:System.Object.GetType%2A> method with the <xref:System.Object.ReferenceEquals%2A> method to determine whether one numeric value is the same type as two other numeric values.
771780
781+
[!INCLUDE[interactive-note](~/includes/csharp-interactive-note-some.md)]
782+
772783
[!code-csharp-interactive[System.Object.GetType#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.object.gettype/cs/gettype1.cs#1)]
773784
[!code-vb[System.Object.GetType#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.object.gettype/vb/gettype1.vb#1)]
774785
@@ -786,8 +797,6 @@ and the <xref:System.IDisposable> interface. The <xref:System.IDisposable.Dispos
786797
787798
## Examples
788799
789-
[!INCLUDE[interactive-note](~/includes/csharp-interactive-note-some.md)]
790-
791800
The following code example demonstrates that <xref:System.Object.GetType%2A> returns the runtime type of the current instance.
792801
793802
[!code-cpp[ECMA-System.Object.GetType#1](~/samples/snippets/cpp/VS_Snippets_CLR/ECMA-System.Object.GetType/CPP/gettype.cpp#1)]
@@ -934,25 +943,28 @@ and the <xref:System.IDisposable> interface. The <xref:System.IDisposable.Dispos
934943
935944
- When comparing value types. If `objA` and `objB` are value types, they are boxed before they are passed to the <xref:System.Object.ReferenceEquals%2A> method. This means that if both `objA` and `objB` represent the same instance of a value type, the <xref:System.Object.ReferenceEquals%2A> method nevertheless returns `false`, as the following example shows.
936945
937-
[!code-csharp[System.Object.ReferenceEquals#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.object.referenceequals/cs/referenceequals4.cs#1)]
946+
[!code-csharp-interactive[System.Object.ReferenceEquals#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.object.referenceequals/cs/referenceequals4.cs#1)]
938947
[!code-vb[System.Object.ReferenceEquals#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.object.referenceequals/vb/referenceequals4.vb#1)]
939948
940949
For information on boxing value types, see [Boxing and Unboxing](~/docs/csharp/programming-guide/types/boxing-and-unboxing.md).
941950
942951
- When comparing strings. If `objA` and `objB` are strings, the <xref:System.Object.ReferenceEquals%2A> method returns `true` if the string is interned. It does not perform a test for value equality. In the following example, `s1` and `s2` are equal because they are two instances of a single interned string. However, `s3` and `s4` are not equal, because although they are have identical string values, that string is not interned.
943952
944-
[!code-csharp[System.Object.ReferenceEquals#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.object.referenceequals/cs/referenceequalsa.cs#2)]
953+
[!code-csharp-interactive[System.Object.ReferenceEquals#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.object.referenceequals/cs/referenceequalsa.cs#2)]
945954
[!code-vb[System.Object.ReferenceEquals#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.object.referenceequals/vb/referenceequalsa.vb#2)]
946955
947956
For more information about string interning, see <xref:System.String.IsInterned%2A?displayProperty=nameWithType>.
948957
949958
950959
951960
## Examples
961+
962+
[!INCLUDE[interactive-note](~/includes/csharp-interactive-note.md)]
963+
952964
The following example uses <xref:System.Object.ReferenceEquals%2A> to determine if two objects are the same instance.
953965
954966
[!code-cpp[ECMA-System.Object.ReferenceEquals#1](~/samples/snippets/cpp/VS_Snippets_CLR/ECMA-System.Object.ReferenceEquals/CPP/referenceequals.cpp#1)]
955-
[!code-csharp[ECMA-System.Object.ReferenceEquals#1](~/samples/snippets/csharp/VS_Snippets_CLR/ECMA-System.Object.ReferenceEquals/CS/referenceequals.cs#1)]
967+
[!code-csharp-interactive[ECMA-System.Object.ReferenceEquals#1](~/samples/snippets/csharp/VS_Snippets_CLR/ECMA-System.Object.ReferenceEquals/CS/referenceequals.cs#1)]
956968
[!code-vb[ECMA-System.Object.ReferenceEquals#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/ECMA-System.Object.ReferenceEquals/vb/referenceequals.vb#1)]
957969
958970
]]></format>
@@ -1008,8 +1020,6 @@ and the <xref:System.IDisposable> interface. The <xref:System.IDisposable.Dispos
10081020
10091021
Types frequently override the <xref:System.Object.ToString%2A?displayProperty=nameWithType> method to provide a more suitable string representation of a particular type. Types also frequently overload the <xref:System.Object.ToString%2A?displayProperty=nameWithType> method to provide support for format strings or culture-sensitive formatting.
10101022
1011-
[!INCLUDE[interactive-note](~/includes/csharp-interactive-note-some.md)]
1012-
10131023
In this section:
10141024
10151025
[The default Object.ToString() method](#Default)
@@ -1022,6 +1032,8 @@ and the <xref:System.IDisposable> interface. The <xref:System.IDisposable.Dispos
10221032
## The default Object.ToString() method
10231033
The default implementation of the <xref:System.Object.ToString%2A> method returns the fully qualified name of the type of the <xref:System.Object>, as the following example shows.
10241034
1035+
[!INCLUDE[interactive-note](~/includes/csharp-interactive-note-some.md)]
1036+
10251037
[!code-cpp[System.Object.ToString#1](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.object.tostring/cpp/tostring1.cpp#1)]
10261038
[!code-csharp-interactive[System.Object.ToString#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.object.tostring/cs/tostring1.cs#1)]
10271039
[!code-vb[System.Object.ToString#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.object.tostring/vb/tostring1.vb#1)]
@@ -1072,6 +1084,8 @@ and the <xref:System.IDisposable> interface. The <xref:System.IDisposable.Dispos
10721084
## Extending the Object.ToString method
10731085
Because a type inherits the default <xref:System.Object.ToString%2A?displayProperty=nameWithType> method, you may find its behavior undesirable and want to change it. This is particularly true of arrays and collection classes. While you may expect the `ToString` method of an array or collection class to display the values of its members, it instead displays the type fully qualified type name, as the following example shows.
10741086
1087+
[!INCLUDE[interactive-note](~/includes/csharp-interactive-note-some.md)]
1088+
10751089
[!code-csharp-interactive[System.Object.ToString#6](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.object.tostring/cs/array1.cs#6)]
10761090
[!code-vb[System.Object.ToString#6](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.object.tostring/vb/array1.vb#6)]
10771091

0 commit comments

Comments
 (0)