Skip to content

VB -> C#: Late bound implicit conversion creates compile error #636

@VetrivelDevOps

Description

@VetrivelDevOps

Input code

txtTotal.Text = Math.Round(sqlDT.Rows(0)("Expr1"), 2)

Erroneous output

txtTotal.Text = Conversions.ToString(Math.Round(sqlDT.Rows[0]["Expr1"], (object)2));

the stack trace.
Error	CS1503	Argument 1: cannot convert from 'object' to 'double'

Expected output

txtTotal.Text = Conversions.ToString(Math.Round(double.Parse(sqlDT.Rows[0]["Expr1"].ToString()), 2));

In C#, Math.Round function expecting 'double' datatype.

Details

  • Product in use: e.g. codeconverter.icsharpcode.net / VS extension / both
  • Version in use: e.g. 5.6.3 or a commit hash (if it's a 3rd party tool using this library, try one of the above)
  • Did you see it working in a previous version, which?
  • Any other relevant information to the issue, or your interest in contributing a fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    VB -> C#Specific to VB -> C# conversioncompilation errorA bug where the converted output won't compile

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions