I’m converting a asp.net application from .NET 2.0 to .NET 3.5
I have loads of inline code like so:
Dim Total = 0
for each dr as DataRow in dt.Rows
Total = Total + dr("SumOfAmount")
next
Response.Write(FormatCurrency(Total,2))
Notice that there is no explicit type declaration of the total variable.
This code worked fine under .NET 2.0
Under .NET 3.5, the Total variable is defined as an Integer, therefore the total is being rounded to the nearest dollar on every pass.
I know one solution is just to change
Dim Total = 0
to either
Dim Total as decimal = 0
or
Dim Total = 0D
However I’d prefer to not have to visit every page in the system looking for this problem.
Is there any site wide, or page wide option I can set the change this behavior back to the way it was under .NET 2.0?
I suspect that you get this behavior because Option Infer is set to On. Setting it to Off will keep the old behavior.
You can change this setting in the project properties page.