2-based, 8-based, 10 credit, 16-en-en-en-enabled conversion (C #)

xiaoxiao2021-03-06  136

In .NET Framework, the SYSTEM.CONVERT class provides a more comprehensive transformation function between various types and values. Two methods of these methods can easily implement the conversions between various enrunters: Convert.Toint32 (string value, int.combase): You can convert different credits strings to numbers, where the FROSE parameter is Format, can only be 2, 8, 10 and 16: such as Convert.TOINT32 ("0010", 2) The result is 2; convert.toString (int value, int tobase): You can convert a number to different envelopes Value string format, where the ToBase parameter is a format, which can only be 2, 8, 10, and 16: as the result of Convert.TOSTRING (2, 2) is "0010" now we do a way to implement various The string of the entry is free conversion: select it into a numeric type, then turn it into the corresponding enrichment string: public string converstring (string value, int.combase, int tobase) {incote = Convert.Toint32 (Value, fromBase); Return Convert.TOSTRING (INTVALUE, TOBASE);} where frombase is the original format TOBASE is the format that will be converted into

转载请注明原文地址:https://www.9cbs.com/read-127122.html

New Post(0)