Skip to content

Commit be3b84e

Browse files
WilliamAntonRohmmairaw
authored andcommitted
Object.GetType -- updating for Try .NET (#3618)
* updating for Try .NET * move note * remove added space
1 parent 27811ff commit be3b84e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

xml/System/Object.xml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -762,22 +762,25 @@ and the <xref:System.IDisposable> interface. The <xref:System.IDisposable.Dispos
762762
763763
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.
764764
765-
[!code-csharp[System.Object.GetType#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.object.gettype/cs/gettype1.cs#1)]
765+
[!code-csharp-interactive[System.Object.GetType#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.object.gettype/cs/gettype1.cs#1)]
766766
[!code-vb[System.Object.GetType#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.object.gettype/vb/gettype1.vb#1)]
767767
768768
> [!NOTE]
769769
> To determine whether an object is a specific type, you can use your language's type comparison keyword or construct. For example, you can use the `TypeOf…Is` construct in Visual Basic or the `is` keyword in C#.
770770
771771
The <xref:System.Object.GetType%2A> method is inherited by all types that derive from <xref:System.Object>. This means that, in addition to using your own language's comparison keyword, you can use the <xref:System.Object.GetType%2A> method to determine the type of a particular object, as the following example shows.
772772
773-
[!code-csharp[System.Object.GetType#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.object.gettype/cs/GetTypeEx2.cs#2)]
773+
[!code-csharp-interactive[System.Object.GetType#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.object.gettype/cs/GetTypeEx2.cs#2)]
774774
[!code-vb[System.Object.GetType#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.object.gettype/vb/GetTypeEx2.vb#2)]
775775
776776
The <xref:System.Type> object exposes the metadata associated with the class of the current <xref:System.Object>.
777777
778778
779779
780780
## Examples
781+
782+
[!INCLUDE[interactive-note](~/includes/csharp-interactive-note-some.md)]
783+
781784
The following code example demonstrates that <xref:System.Object.GetType%2A> returns the runtime type of the current instance.
782785
783786
[!code-cpp[ECMA-System.Object.GetType#1](~/samples/snippets/cpp/VS_Snippets_CLR/ECMA-System.Object.GetType/CPP/gettype.cpp#1)]

0 commit comments

Comments
 (0)