|
-
July 15th, 2010, 08:02 AM
#1
ToString format causes InvalidCastException
I am using .ToString("#,##0.00") to format a number.
I'm sure I have used this before but today it doesn't work.
I want to format a System.Double value from the datatable like this 12345.6789 to 12,345.68
Code:
myString = dt.Rows(i)("column_name").ToString("#,##0.00")
gives a System.InvalidCastException:
Conversion from string "#,##0.00" to type 'Integer' is not valid.
Any ideas?
I'm using .NET Framework 3.5
I'm planning to be spontaneous tomorrow
-
July 21st, 2010, 08:00 AM
#2
Re: ToString format causes InvalidCastException
Try:
dt.Rows(i)("column_name").Value.ToString("#,##0.00")
instead.
-tg
-
July 21st, 2010, 02:14 PM
#3
Re: ToString format causes InvalidCastException
You'd could use String.Format()
Code:
Code:
String.Format(dt.Rows(i)("column_name").Value.ToString,{0:#,##0.00}
Or something like that
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|