c# - Specify NumberFormat at app level -
i'm reading data json jsonconvert , jsonserializersettings, haven't touched culture. changing phone os language en-us nl-nl lose numberformat. possible set numberformat app?
using (stream stream = accessstream.asstreamforread((int)accessstream.size)) { byte[] content = new byte[stream.length]; await stream.readasync(content, 0, (int)stream.length); string json = encoding.utf8.getstring(content, 0, content.length); system.diagnostics.debug.writeline("read file: " + json); jsonserializersettings serializersettings = new jsonserializersettings(); serializersettings.nullvaluehandling = nullvaluehandling.ignore; list<t> objects = jsonconvert.deserializeobject<list<t>>(json, serializersettings); return objects; }
you try this:
thread.currentthread.currentuiculture.numberformat = new numberformatinfo(); // sets currenuiculture number format default culture neutral format
in asp.net config file change using next section. well, won't if not asp.net app.
there difference between current culture , uiculture - currentuiculture responsible formatting , other features, while currentculture deals language , resources.
but should know snippet change number format entire main thread in app. , won't affect number formats in threads.
off-topic suggestion? :
if need change json serialization-deserialization should use culture property of jsonserializersettings
jsonserializersettings serializersettings = new jsonserializersettings() {culture = cultureinfo.invariantculture };
Comments
Post a Comment