dotnet / dotnet/dotnet-api-docs
Incorrect side note about VB.NET in Decimal.ToDouble
- Dominant language
- C#
- Stars
- 949
- Forks
- 1.7k
- Avg merge
- 3d 27m
- Merged PRs (30d)
- 49
Description
### Describe the issue or suggestion
The "Remarks" section of [Decimal.ToDouble](https://learn.microsoft.com/en-us/dotnet/api/system.decimal.todouble?view=net-9.0) contains the following paragraph:
> You can also convert a [Decimal](https://learn.microsoft.com/en-us/dotnet/api/system.decimal?view=net-9.0) to a [Double](https://learn.microsoft.com/en-us/dotnet/api/system.double?view=net-9.0) value by using the [Explicit](https://learn.microsoft.com/en-us/dotnet/api/system.decimal.op_explicit?view=net-9.0) assignment operator. Because the conversion can entail a loss of precision, you must use a casting operator in C# or a conversion function in Visual Basic.
The last part of the last sentence ("or a conversion function in Visual Basic") is incorrect. VB.NET (unfortunately) allows implicit conversions from Decimal to Double, even with Option Strict On (cf. Section 8.3 of the VB 11 language specification).
Suggested fix:
> You can also convert a [Decimal](https://learn.microsoft.com/en-us/dotnet/api/system.decimal?view=net-9.0) to a [Double](https://learn.microsoft.com/en-us/dotnet/api/system.double?view=net-9.0) value by using the [Explicit](https://learn.microsoft.com/en-us/dotnet/api/system.decimal.op_explicit?view=net-9.0) assignment operator. Because the conversion can entail a loss of precision, you must use a casting operator in C#. Visual Basic supports implicit conversions from Double to Decimal, rounding to the nearest Double value.
Alternatively, we could just drop the part about Visual Basic (= suggested fix minus the last sentence).
Contributor guide
Assessment
This issue has not been assessed yet.