|
295 | 295 | <block subset="none" type="usage">
|
296 | 296 | <para>The <see cref="M:System.Convert.ChangeType(System.Object,System.Type)" /> method can convert an enumeration value to another type. However, it cannot convert another type to an enumeration value, even if the source type is the underlying type of the enumeration. To convert a type to an enumeration value, use a casting operator (in C#) or a conversion function (in Visual Basic). The following example illustrates the conversion to and from a <c>Continent</c> enumeration value.
|
297 | 297 |
|
298 |
| - [!code-csharp[System.Convert.ChangeType#5](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.convert.changetype/cs/changetype_enum2.cs#5)] |
299 |
| - [!code-vb[System.Convert.ChangeType#5](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.convert.changetype/vb/changetype_enum2.vb#5)] |
300 |
| - |
| 298 | + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.convert.changetype/cs/changetype_enum2.cs" interactive="try-dotnet" id="Snippet5"::: |
| 299 | + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.convert.changetype/vb/changetype_enum2.vb" id="Snippet5"::: |
| 300 | + |
301 | 301 | The <see cref="M:System.Convert.ChangeType(System.Object,System.Type)" /> method can convert a nullable type to another type. However, it cannot convert another type to a value of a nullable type, even if <paramref name="conversionType" /> is the underlying type of the <see cref="T:System.Nullable`1" />.To perform the conversion, you can use a casting operator (in C#) or a conversion function (in Visual Basic). The following example illustrates the conversion to and from a nullable type.
|
302 |
| - |
303 |
| - [!code-csharp[System.Convert.ChangeType#7](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.convert.changetype/cs/changetype_nullable.cs#7)] |
304 |
| - [!code-vb[System.Convert.ChangeType#7](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.convert.changetype/vb/changetype_nullable.vb#7)]</para> |
| 302 | + |
| 303 | + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.convert.changetype/cs/changetype_nullable.cs" interactive="try-dotnet" id="Snippet7"::: |
| 304 | + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.convert.changetype/vb/changetype_nullable.vb" id="Snippet7"::: </para> |
305 | 305 | </block>
|
306 | 306 | </Docs>
|
307 | 307 | </Member>
|
|
497 | 497 | <paramref name="conversionType" /> is <see langword="null" />.</exception>
|
498 | 498 | <block subset="none" type="usage">
|
499 | 499 | <para>The <see cref="M:System.Convert.ChangeType(System.Object,System.Type,System.IFormatProvider)" /> method can convert an enumeration value to another type. However, it cannot convert another type to an enumeration value, even if the source type is the underlying type of the enumeration. To convert a type to an enumeration value, use a casting operator (in C#) or a conversion function (in Visual Basic). The following example illustrates the conversion to and from a <c>Continent</c> enumeration value.
|
500 |
| - |
501 |
| - [!code-csharp[System.Convert.ChangeType#5](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.convert.changetype/cs/changetype_enum2.cs#5)] |
502 |
| - [!code-vb[System.Convert.ChangeType#5](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.convert.changetype/vb/changetype_enum2.vb#5)] |
| 500 | + |
| 501 | + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.convert.changetype/cs/changetype_enum2.cs" interactive="try-dotnet" id="Snippet5"::: |
| 502 | + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.convert.changetype/vb/changetype_enum2.vb" id="Snippet5"::: |
503 | 503 |
|
504 | 504 | The <see cref="M:System.Convert.ChangeType(System.Object,System.Type,System.IFormatProvider)" /> method can convert a nullable type to another type. However, it cannot convert another type to a value of a nullable type, even if <paramref name="conversionType" /> is the underlying type of the <see cref="T:System.Nullable`1" />. To perform the conversion, you can use a casting operator (in C#) or a conversion function (in Visual Basic). The following example illustrates the conversion to and from a nullable type.
|
505 |
| - |
506 |
| - [!code-csharp[System.Convert.ChangeType#8](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.convert.changetype/cs/changetype_nullable_1.cs#8)] |
507 |
| - [!code-vb[System.Convert.ChangeType#8](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.convert.changetype/vb/changetype_nullable_1.vb#8)]</para> |
| 505 | + |
| 506 | + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.convert.changetype/cs/changetype_nullable_1.cs" interactive="try-dotnet" id="Snippet8"::: |
| 507 | + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.convert.changetype/vb/changetype_nullable_1.vb" id="Snippet8":::</para> |
508 | 508 | </block>
|
509 | 509 | </Docs>
|
510 | 510 | </Member>
|
|
0 commit comments