Convert SharePoint Number to C# Float


I've a SharePoint Site in French (SP 2007). On this machine, Windows is also in French.

In a list, I've a calculated field with the data type "Nombre" (number) with 2 decimals.

When I get this number in C# : oSPList.Items[0]["CalculatedField"].ToString(), I have this string "float;#0.23454" and of course I can't convert it to C# float.

How can I convert a number from french SharePoint to a float C# ?

Thanks in advance

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ted BouskillSenior Software DeveloperCommented:
Have you tried Convert.ToFloat(oSPList.Items[0]["CalculatedField"].Value)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
convert this no to string and use  string.Trim() to remove until '#'.. now convert string to float and use
Ted BouskillSenior Software DeveloperCommented:
Two answers were provided and you did not give any feedback as to why they didn't succeed.
The 7 Worst Nightmares of a Sysadmin

Fear not! To defend your business’ IT systems we’re going to shine a light on the seven most sinister terrors that haunt sysadmins. That way you can be sure there’s nothing in your stack waiting to go bump in the night.

GhislainBruyereAuthor Commented:
I would like a more flexible solution for other language.

I don't understand why oSPList.Items[0]["CalculatedField"].ToString() is language depedend
Ted BouskillSenior Software DeveloperCommented:
Why didn't you try my recommendation?  It is platform independent.
GhislainBruyereAuthor Commented:
Sorry missunderstoof
Using SP2010 and ran into the same issue. There is no Value() method for SPListItem["fieldname"] and there is no Convert.ToFloat() either. Any suggestion? Thanks much.
ok, in SP2010 you can achieve this by:

double c_sharp_number = 0;
bool success = double.TryParse(SPListItem.GetFormattedValue("SP_CALCULATED_NUMBER"), out c_sharp_number);

The SP field "SP_CALCULATED_NUMBER" has the following string value "float;#12.80000". c_sharp_number has the value 12.8

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SharePoint

From novice to tech pro — start learning today.