C
C#2y ago
Gaandalf

❔ Culture based Type Conversions

Hello, There is a problem in my wpf app, while convertring types using Convert class we have to define IFormatProvider at every method, is there a way to set CultureInfo to CultureInfo.InvariantCulture as default, there is too much type conversions in the project and it's so hard to add every conversions to this parameter.
18 Replies
ero
ero2y ago
Don't use convert, and it's not hard.
Gaandalf
GaandalfOP2y ago
it's not hard? its not school project, there is thousands conversion harold
ero
ero2y ago
And?
Gaandalf
GaandalfOP2y ago
so its not easy
ero
ero2y ago
I don't see the problem
Gaandalf
GaandalfOP2y ago
there is might be a option manipulate program's default culture that will solve problem
TheRanger
TheRanger2y ago
what are u trying to convert anyway?
ero
ero2y ago
I don't see that as a "solution" personally
Gaandalf
GaandalfOP2y ago
double to string, string to double then what's your solution harold = new CultureInfo("en-US"); that's might help to me
ero
ero2y ago
No shot you're using Convert to convert a number to a string Absolutely zero way
TheRanger
TheRanger2y ago
yeah use .ToString() and double.Parse methods
Gaandalf
GaandalfOP2y ago
i can think that, but its too hard to change every method
TheRanger
TheRanger2y ago
or double.TryParse if you want to validate the number
ero
ero2y ago
Your entire project is already completely messed up. At this point, i guess you can use some weird hack
Gaandalf
GaandalfOP2y ago
i meant that, maybe there is a easy solution yeah i mean it
ero
ero2y ago
It's hard to believe that you even successfully wrote a thousand lines of code while using Convert It can't be that much
Gaandalf
GaandalfOP2y ago
i didn't wrote, its legacy project
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server