如何将字符串中的值从0,00更改为0.00

use*_*186 4 .net c#

如何将字符串中的值从0,00更改为0.00? - 只有数字值,而不是所有字符","到"."

string myInputString = "<?xml version=\"1.0\"?>\n<List xmlns:Table=\"urn:www.navision.com/Formats/Table\"><Row><HostelMST>12,0000</HostelMST><PublicMST>0,0000</PublicMST><TaxiMST>0,0000</TaxiMST><ParkMST>0,0000</ParkMST><RoadMST>0,0000</RoadMST><FoodMST>0,0000</FoodMST><ErrorCode>0</ErrorCode><ErrorDescription></ErrorDescription></Row></List>\n";
Run Code Online (Sandbox Code Playgroud)

string myInputString = "<?xml version=\"1.0\"?>\n<List xmlns:Table=\"urn:www.navision.com/Formats/Table\"><Row><HostelMST>12.0000</HostelMST><PublicMST>0.0000</PublicMST><TaxiMST>0.0000</TaxiMST><ParkMST>0.0000</ParkMST><RoadMST>0.0000</RoadMST><FoodMST>0.0000</FoodMST><ErrorCode>0</ErrorCode><ErrorDescription></ErrorDescription></Row></List>\n";
Run Code Online (Sandbox Code Playgroud)

感谢您的回答,但我的意思是只更改数值,而不是所有字符","更改为"." 我不希望改变字符串

string = "<Attrib>txt txt, txt</Attrib><Attrib1>12,1223</Attrib1>";
Run Code Online (Sandbox Code Playgroud)

string = "<Attrib>txt txt. txt</Attrib><Attrib1>12.1223</Attrib1>";
Run Code Online (Sandbox Code Playgroud)

但是这个还可以

string = "<Attrib>txt txt, txt</Attrib><Attrib1>12.1223</Attrib1>";
Run Code Online (Sandbox Code Playgroud)

Can*_*var 5

试试这个 :

Regex.Replace("attrib1='12,34' attrib2='43,22'", "(\\d),(\\d)", "$1.$2")
Run Code Online (Sandbox Code Playgroud)

输出: attrib1 = '12 .34'attrib2 = '43 .22'