Nugs
asked on
Vb.Net to C# conversion (cont.) - Microsoft.VisualBasic
What is the C# equivilent to
Microsoft.VisualBasic.Stri ngs.Format Currency()
Microsoft.VisualBasic.TriS tate.UseDe fault
I have this line of code that is no longer working:
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- --------
using Microsoft.VisualBasic;
...
Session["TotalCost"] = Strings.FormatCurrency(cal culatedTot alValue, 2, TriState.UseDefault, TriState.UseDefault, TriState.UseDefault);
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- --------
Nugs
Microsoft.VisualBasic.Stri
Microsoft.VisualBasic.TriS
I have this line of code that is no longer working:
--------------------------
using Microsoft.VisualBasic;
...
Session["TotalCost"] = Strings.FormatCurrency(cal
--------------------------
Nugs
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I basically need to convert calculatedTotalValue to a currency format with 2 decimal places.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Original code does not work in C#...
ASKER
What about: Session["TotalCost"] = String.Format("{0:c}", calculatedTotalValue);
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
That too. It's just a longhand version of calculatedTotalValue.ToStr ing("c")
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok, one more Microsoft.VisualBasic conversion...
Dim NumberOfDaysDifference As Integer = DateDiff(DateInterval.Day, Convert.ToDateTime(strStar tDate), Convert.ToDateTime(EndDate ))
The original VB code is working out the number of days between the start and end date... What woudl the C# equivilent be?
Nugs
Dim NumberOfDaysDifference As Integer = DateDiff(DateInterval.Day,
The original VB code is working out the number of days between the start and end date... What woudl the C# equivilent be?
Nugs
ASKER
nevermind, something like this should work...
int NumberOfDaysDifference = ((TimeSpan)(Convert.ToDate Time(EndDa te) - Convert.ToDateTime(strStar tDate))).D ays;
Nugs...
int NumberOfDaysDifference = ((TimeSpan)(Convert.ToDate
Nugs...
int numberOfDaysDifference = DateTime.Parse(startDate). Subtract(D ateTime.Pa rse(endDat e)).TotalD ays;
Bob
Bob
ASKER
Ohhh that one is cool....
I bring this up just to point out that simply adding a 'using' is not enough if the correct assembly reference does not exist.