C#利用字符串方法把八进制数转换为十六进制数

<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;summary&gt;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-size: small;"><span style="" lang="EN-US"><span style=""><span style="color: #000000;"> </span></span><span style="color: gray;">///</span><span style="color: green;"> </span></span><span style="">将8进制数转换成16进制数<span lang="EN-US"></span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;/summary&gt;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-size: small;"><span style="" lang="EN-US"><span style=""><span style="color: #000000;"> </span></span><span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;param name="convertFrom"&gt;</span></span><span style="">八进制数</span><span style="" lang="EN-US">&lt;/param&gt;</span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-size: small;"><span style="" lang="EN-US"><span style=""><span style="color: #000000;"> </span></span><span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;returns&gt;</span></span><span style="">十六进制数</span><span style="" lang="EN-US">&lt;/returns&gt;</span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">private</span><span style="color: #000000;"> </span><span style="color: blue;">string</span><span style="color: #000000;"> <span style="color: black;">ConvertNumber8To16</span>(</span><span style="color: blue;">string</span><span style="color: #000000;"> <span style="color: black;">convertFrom</span>)</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span>{</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">string</span><span style="color: #000000;"> <span style="color: black;">check</span> = <span style="color: black;">convertFrom</span>.<span style="color: black;">Replace</span>(</span><span style="color: maroon;">"0"</span><span style="color: #000000;">, </span><span style="color: blue;">string</span><span style="color: #000000;">.<span style="color: black;">Empty</span>).<span style="color: black;">Replace</span>(</span><span style="color: maroon;">"1"</span><span style="color: #000000;">, </span><span style="color: blue;">string</span><span style="color: #000000;">.<span style="color: black;">Empty</span>).<span style="color: black;">Replace</span>(</span><span style="color: maroon;">"2"</span><span style="color: #000000;">, </span><span style="color: blue;">string</span><span style="color: #000000;">.<span style="color: black;">Empty</span>).<span style="color: black;">Replace</span>(</span><span style="color: maroon;">"3"</span><span style="color: #000000;">, </span><span style="color: blue;">string</span><span style="color: #000000;">.<span style="color: black;">Empty</span>).<span style="color: black;">Replace</span>(</span><span style="color: maroon;">"4"</span><span style="color: #000000;">, </span><span style="color: blue;">string</span><span style="color: #000000;">.<span style="color: black;">Empty</span>).<span style="color: black;">Replace</span>(</span><span style="color: maroon;">"5"</span><span style="color: #000000;">, </span><span style="color: blue;">string</span><span style="color: #000000;">.<span style="color: black;">Empty</span>).<span style="color: black;">Replace</span>(</span><span style="color: maroon;">"6"</span><span style="color: #000000;">, </span><span style="color: blue;">string</span><span style="color: #000000;">.<span style="color: black;">Empty</span>).<span style="color: black;">Replace</span>(</span><span style="color: maroon;">"7"</span><span style="color: #000000;">, </span><span style="color: blue;">string</span><span style="color: #000000;">.<span style="color: black;">Empty</span>);</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">if</span><span style="color: #000000;"> (<span style="color: black;">check</span>.<span style="color: black;">Length</span> &gt; 0)</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span>{</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: green;">//errorHandle</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">return</span><span style="color: #000000;"> </span><span style="color: blue;">string</span><span style="color: #000000;">.<span style="color: black;">Empty</span>;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span>}</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-size: small;"><span style="" lang="EN-US"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">string</span><span style="color: #000000;"> <span style="color: black;">convertTo</span>=</span><span style="color: blue;">string</span><span style="color: #000000;">.<span style="color: black;">Empty</span>, <span style="color: black;">convertTo2</span>;</span><span style="color: green;">//</span></span><span style="">目标数<span lang="EN-US">convertTo</span>:将八进制<span lang="EN-US">From</span>转换成进制<span lang="EN-US">To,</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-size: small;"><span style="" lang="EN-US"><span style=""><span style="color: #000000;"> </span></span><span style="color: green;">//convertTo2</span></span><span style="">:选转换成进制数,再转换成十六进制数<span lang="EN-US"></span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-size: small;"><span style="" lang="EN-US"><span style="color: #000000;"><span style=""> </span><span style="color: black;">convertTo2</span> = <span style="color: black;">ConvertNumber8To2</span>(<span style="color: black;">convertFrom</span>);</span><span style="color: green;">//</span></span><span style="">先转化为二进制<span lang="EN-US"></span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span><span style="color: black;">convertTo</span> = <span style="color: black;">ConvertNumber2To16</span>(<span style="color: black;">convertTo2</span>);</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">return</span><span style="color: #000000;"> <span style="color: black;">convertTo</span>;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span>}</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;summary&gt;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-size: small;"><span style="" lang="EN-US"><span style=""><span style="color: #000000;"> </span></span><span style="color: gray;">///</span><span style="color: green;"> </span></span><span style="">将8进制转换为2进制<span lang="EN-US"></span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;/summary&gt;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-size: small;"><span style="" lang="EN-US"><span style=""><span style="color: #000000;"> </span></span><span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;param name="convertFrom"&gt;</span></span><span style="">八进制数</span><span style="" lang="EN-US">&lt;/param&gt;</span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-size: small;"><span style="" lang="EN-US"><span style=""><span style="color: #000000;"> </span></span><span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;returns&gt;</span></span><span style="">二进制数</span><span style="" lang="EN-US">&lt;/returns&gt;</span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">private</span><span style="color: #000000;"> </span><span style="color: blue;">string</span><span style="color: #000000;"> <span style="color: black;">ConvertNumber8To2</span>(</span><span style="color: blue;">string</span><span style="color: #000000;"> <span style="color: black;">convertFrom</span>)</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span>{</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">string</span><span style="color: #000000;"> <span style="color: black;">check</span> = <span style="color: black;">convertFrom</span>.<span style="color: black;">Replace</span>(</span><span style="color: maroon;">"0"</span><span style="color: #000000;">, </span><span style="color: blue;">string</span><span style="color: #000000;">.<span style="color: black;">Empty</span>).<span style="color: black;">Replace</span>(</span><span style="color: maroon;">"1"</span><span style="color: #000000;">, </span><span style="color: blue;">string</span><span style="color: #000000;">.<span style="color: black;">Empty</span>).<span style="color: black;">Replace</span>(</span><span style="color: maroon;">"2"</span><span style="color: #000000;">, </span><span style="color: blue;">string</span><span style="color: #000000;">.<span style="color: black;">Empty</span>).<span style="color: black;">Replace</span>(</span><span style="color: maroon;">"3"</span><span style="color: #000000;">, </span><span style="color: blue;">string</span><span style="color: #000000;">.<span style="color: black;">Empty</span>).<span style="color: black;">Replace</span>(</span><span style="color: maroon;">"4"</span><span style="color: #000000;">, </span><span style="color: blue;">string</span><span style="color: #000000;">.<span style="color: black;">Empty</span>).<span style="color: black;">Replace</span>(</span><span style="color: maroon;">"5"</span><span style="color: #000000;">, </span><span style="color: blue;">string</span><span style="color: #000000;">.<span style="color: black;">Empty</span>).<span style="color: black;">Replace</span>(</span><span style="color: maroon;">"6"</span><span style="color: #000000;">, </span><span style="color: blue;">string</span><span style="color: #000000;">.<span style="color: black;">Empty</span>).<span style="color: black;">Replace</span>(</span><span style="color: maroon;">"7"</span><span style="color: #000000;">, </span><span style="color: blue;">string</span><span style="color: #000000;">.<span style="color: black;">Empty</span>);</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">if</span><span style="color: #000000;"> (<span style="color: black;">check</span>.<span style="color: black;">Length</span> &gt; 0)</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span>{</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: green;">//errorHandle</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">return</span><span style="color: #000000;"> </span><span style="color: blue;">string</span><span style="color: #000000;">.<span style="color: black;">Empty</span>;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span>}</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">string</span><span style="color: #000000;"> <span style="color: black;">convertTo</span> = </span><span style="color: blue;">string</span><span style="color: #000000;">.<span style="color: black;">Empty</span>, <span style="color: black;">bit</span>;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">for</span><span style="color: #000000;"> (</span><span style="color: blue;">int</span><span style="color: #000000;"> <span style="color: black;">i</span> = <span style="color: black;">convertFrom</span>.<span style="color: black;">Length</span> - 1; <span style="color: black;">i</span> &gt;= 0; <span style="color: black;">i</span>--)</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span>{</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span><span style="color: black;">bit</span> = <span style="color: black;">convertFrom</span>.<span style="color: black;">Substring</span>(<span style="color: black;">i</span>, 1);</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">switch</span><span style="color: #000000;"> (<span style="color: black;">bit</span>)</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span>{</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">case</span><span style="color: #000000;"> </span><span style="color: maroon;">"0"</span><span style="color: #000000;">:</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span><span style="color: black;">convertTo</span> = </span><span style="color: maroon;">"000"</span><span style="color: #000000;"> + <span style="color: black;">convertTo</span>;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">break</span><span style="color: #000000;">;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">case</span><span style="color: #000000;"> </span><span style="color: maroon;">"1"</span><span style="color: #000000;">:</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span><span style="color: black;">convertTo</span> = </span><span style="color: maroon;">"001"</span><span style="color: #000000;"> + <span style="color: black;">convertTo</span>;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">break</span><span style="color: #000000;">;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">case</span><span style="color: #000000;"> </span><span style="color: maroon;">"2"</span><span style="color: #000000;">:</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span><span style="color: black;">convertTo</span> = </span><span style="color: maroon;">"010"</span><span style="color: #000000;"> + <span style="color: black;">convertTo</span>;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span><span style=""></span></span><span style="color: blue;">break</span><span style="color: #000000;">;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">case</span><span style="color: #000000;"> </span><span style="color: maroon;">"3"</span><span style="color: #000000;">:</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span><span style="color: black;">convertTo</span> = </span><span style="color: maroon;">"011"</span><span style="color: #000000;"> + <span style="color: black;">convertTo</span>;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">break</span><span style="color: #000000;">;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">case</span><span style="color: #000000;"> </span><span style="color: maroon;">"4"</span><span style="color: #000000;">:</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span><span style="color: black;">convertTo</span> = </span><span style="color: maroon;">"100"</span><span style="color: #000000;"> + <span style="color: black;">convertTo</span>;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">break</span><span style="color: #000000;">;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span><span style=""></span></span><span style="color: blue;">case</span><span style="color: #000000;"> </span><span style="color: maroon;">"5"</span><span style="color: #000000;">:</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span><span style="color: black;">convertTo</span> = </span><span style="color: maroon;">"101"</span><span style="color: #000000;"> + <span style="color: black;">convertTo</span>;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">break</span><span style="color: #000000;">;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">case</span><span style="color: #000000;"> </span><span style="color: maroon;">"6"</span><span style="color: #000000;">:</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span><span style="color: black;">convertTo</span> = </span><span style="color: maroon;">"110"</span><span style="color: #000000;"> + <span style="color: black;">convertTo</span>;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">break</span><span style="color: #000000;">;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">case</span><span style="color: #000000;"> </span><span style="color: maroon;">"7"</span><span style="color: #000000;">:</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span><span style="color: black;">convertTo</span> = </span><span style="color: maroon;">"111"</span><span style="color: #000000;"> + <span style="color: black;">convertTo</span>;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">break</span><span style="color: #000000;">;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span>}</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span>}</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">return</span><span style="color: #000000;"> <span style="color: black;">convertTo</span>;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span>}</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;summary&gt;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-size: small;"><span style="" lang="EN-US"><span style=""><span style="color: #000000;"> </span></span><span style="color: gray;">///</span><span style="color: green;"> </span></span><span style="">将2进制转换为16进制<span lang="EN-US"></span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;/summary&gt;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-size: small;"><span style="" lang="EN-US"><span style=""><span style="color: #000000;"> </span></span><span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;param name="convertFrom"&gt;</span></span><span style="">二进制数</span><span style="" lang="EN-US">&lt;/param&gt;</span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-size: small;"><span style="" lang="EN-US"><span style=""><span style="color: #000000;"> </span></span><span style="color: gray;">///</span><span style="color: green;"> </span><span style="color: gray;">&lt;returns&gt;</span></span><span style="">十六进制数</span><span style="" lang="EN-US">&lt;/returns&gt;</span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">private</span><span style="color: #000000;"> </span><span style="color: blue;">string</span><span style="color: #000000;"> <span style="color: black;">ConvertNumber2To16</span>(</span><span style="color: blue;">string</span><span style="color: #000000;"> <span style="color: black;">convertFrom</span>)</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span>{</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">string</span><span style="color: #000000;"> <span style="color: black;">check</span> = <span style="color: black;">convertFrom</span>.<span style="color: black;">Replace</span>(</span><span style="color: maroon;">"0"</span><span style="color: #000000;">, </span><span style="color: blue;">string</span><span style="color: #000000;">.<span style="color: black;">Empty</span>).<span style="color: black;">Replace</span>(</span><span style="color: maroon;">"1"</span><span style="color: #000000;">, </span><span style="color: blue;">string</span><span style="color: #000000;">.<span style="color: black;">Empty</span>);</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">if</span><span style="color: #000000;"> (<span style="color: black;">check</span>.<span style="color: black;">Length</span> &gt; 0)</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span>{</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: green;">//errorHandle</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">return</span><span style="color: #000000;"> </span><span style="color: blue;">string</span><span style="color: #000000;">.<span style="color: black;">Empty</span>;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span>}</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">string</span><span style="color: #000000;"> <span style="color: black;">convertTo</span> = </span><span style="color: blue;">string</span><span style="color: #000000;">.<span style="color: black;">Empty</span>, <span style="color: black;">bit</span>;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">int</span><span style="color: #000000;"> <span style="color: black;">residue</span>,<span style="color: black;">temp</span> = 0;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">for</span><span style="color: #000000;"> (</span><span style="color: blue;">int</span><span style="color: #000000;"> <span style="color: black;">i</span> = <span style="color: black;">convertFrom</span>.<span style="color: black;">Length</span> - 4; <span style="color: black;">i</span> &gt;= 0; <span style="color: black;">i</span>-=4)</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span>{</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-size: small;"><span style="" lang="EN-US"><span style="color: #000000;"><span style=""> </span><span style="color: black;">bit</span> = <span style="color: black;">convertFrom</span>.<span style="color: black;">Substring</span>(<span style="color: black;">i</span>, 4);</span><span style="color: green;">//</span></span><span style="">每次减四<span lang="EN-US"></span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">switch</span><span style="color: #000000;"> (<span style="color: black;">bit</span>)</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span>{</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">case</span><span style="color: #000000;"> </span><span style="color: maroon;">"0000"</span><span style="color: #000000;">:</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span><span style="color: black;">convertTo</span> = </span><span style="color: maroon;">"0"</span><span style="color: #000000;"> + <span style="color: black;">convertTo</span>;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">break</span><span style="color: #000000;">;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">case</span><span style="color: #000000;"> </span><span style="color: maroon;">"0001"</span><span style="color: #000000;">:</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span><span style="color: black;">convertTo</span> = </span><span style="color: maroon;">"1"</span><span style="color: #000000;"> + <span style="color: black;">convertTo</span>;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">break</span><span style="color: #000000;">;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">case</span><span style="color: #000000;"> </span><span style="color: maroon;">"0010"</span><span style="color: #000000;">:</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span><span style="color: black;">convertTo</span> = </span><span style="color: maroon;">"2"</span><span style="color: #000000;"> + <span style="color: black;">convertTo</span>;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">break</span><span style="color: #000000;">;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">case</span><span style="color: #000000;"> </span><span style="color: maroon;">"0011"</span><span style="color: #000000;">:</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span><span style="color: black;">convertTo</span> = </span><span style="color: maroon;">"3"</span><span style="color: #000000;"> + <span style="color: black;">convertTo</span>;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">break</span><span style="color: #000000;">;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">case</span><span style="color: #000000;"> </span><span style="color: maroon;">"0100"</span><span style="color: #000000;">:</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span><span style="color: black;">convertTo</span> = </span><span style="color: maroon;">"4"</span><span style="color: #000000;"> + <span style="color: black;">convertTo</span>;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">break</span><span style="color: #000000;">;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">case</span><span style="color: #000000;"> </span><span style="color: maroon;">"0101"</span><span style="color: #000000;">:</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span><span style=""></span><span style="color: black;">convertTo</span> = </span><span style="color: maroon;">"5"</span><span style="color: #000000;"> + <span style="color: black;">convertTo</span>;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">break</span><span style="color: #000000;">;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">case</span><span style="color: #000000;"> </span><span style="color: maroon;">"0110"</span><span style="color: #000000;">:</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span><span style="color: black;">convertTo</span> = </span><span style="color: maroon;">"6"</span><span style="color: #000000;"> + <span style="color: black;">convertTo</span>;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">break</span><span style="color: #000000;">;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">case</span><span style="color: #000000;"> </span><span style="color: maroon;">"0111"</span><span style="color: #000000;">:</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span><span style="color: black;">convertTo</span> = </span><span style="color: maroon;">"7"</span><span style="color: #000000;"> + <span style="color: black;">convertTo</span>;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">break</span><span style="color: #000000;">;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">case</span><span style="color: #000000;"> </span><span style="color: maroon;">"1000"</span><span style="color: #000000;">:</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span><span style="color: black;">convertTo</span> = </span><span style="color: maroon;">"8"</span><span style="color: #000000;"> + <span style="color: black;">convertTo</span>;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">break</span><span style="color: #000000;">;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">case</span><span style="color: #000000;"> </span><span style="color: maroon;">"1001"</span><span style="color: #000000;">:</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span><span style="color: black;">convertTo</span> = </span><span style="color: maroon;">"9"</span><span style="color: #000000;"> + <span style="color: black;">convertTo</span>;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">break</span><span style="color: #000000;">;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">case</span><span style="color: #000000;"> </span><span style="color: maroon;">"1010"</span><span style="color: #000000;">:</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span><span style="color: black;">convertTo</span> = </span><span style="color: maroon;">"A"</span><span style="color: #000000;"> + <span style="color: black;">convertTo</span>;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">break</span><span style="color: #000000;">;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">case</span><span style="color: #000000;"> </span><span style="color: maroon;">"1011"</span><span style="color: #000000;">:</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span><span style="color: black;">convertTo</span> = </span><span style="color: maroon;">"B"</span><span style="color: #000000;"> + <span style="color: black;">convertTo</span>;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span><span style=""></span></span><span style="color: blue;">break</span><span style="color: #000000;">;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">case</span><span style="color: #000000;"> </span><span style="color: maroon;">"1100"</span><span style="color: #000000;">:</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span><span style="color: black;">convertTo</span> = </span><span style="color: maroon;">"C"</span><span style="color: #000000;"> + <span style="color: black;">convertTo</span>;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">break</span><span style="color: #000000;">;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">case</span><span style="color: #000000;"> </span><span style="color: maroon;">"1101"</span><span style="color: #000000;">:</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span><span style="color: black;">convertTo</span> = </span><span style="color: maroon;">"D"</span><span style="color: #000000;"> + <span style="color: black;">convertTo</span>;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">break</span><span style="color: #000000;">;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">case</span><span style="color: #000000;"> </span><span style="color: maroon;">"1110"</span><span style="color: #000000;">:</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span><span style="color: black;">convertTo</span> = </span><span style="color: maroon;">"E"</span><span style="color: #000000;"> + <span style="color: black;">convertTo</span>;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">break</span><span style="color: #000000;">;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">case</span><span style="color: #000000;"> </span><span style="color: maroon;">"1111"</span><span style="color: #000000;">:</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span><span style="color: black;">convertTo</span> = </span><span style="color: maroon;">"F"</span><span style="color: #000000;"> + <span style="color: black;">convertTo</span>;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">break</span><span style="color: #000000;">;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span>}</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span><span style=""></span>}<span style=""> </span></span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-size: small;"><span style="" lang="EN-US"><span style="color: #000000;"><span style=""> </span><span style="color: black;">residue</span> = <span style="color: black;">convertFrom</span>.<span style="color: black;">Length</span> % 4;</span><span style="color: green;">//</span></span><span style="">求余数<span lang="EN-US"></span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">if</span><span style="color: #000000;"> (<span style="color: black;">residue</span> != 0)</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span>{</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">for</span><span style="color: #000000;"> (</span><span style="color: blue;">int</span><span style="color: #000000;"> <span style="color: black;">i</span> = 0; <span style="color: black;">i</span> &lt; <span style="color: black;">residue</span>; <span style="color: black;">i</span>++)</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span>{</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span><span style="color: black;">temp</span> += </span><span style="color: teal;">Convert</span><span style="color: #000000;">.<span style="color: black;">ToInt32</span>(<span style="color: black;">convertFrom</span>.<span style="color: black;">Substring</span>(<span style="color: black;">i</span>, 1))</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span>* </span><span style="color: teal;">Convert</span><span style="color: #000000;">.<span style="color: black;">ToInt32</span>(</span><span style="color: teal;">Math</span><span style="color: #000000;">.<span style="color: black;">Pow</span>(2, <span style="color: black;">residue</span> - <span style="color: black;">i</span> - 1));</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span>}</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span>}</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">if</span><span style="color: #000000;"> (<span style="color: black;">temp</span> != 0)</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span>{</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span><span style="color: black;">convertTo</span> = <span style="color: black;">temp</span>.<span style="color: black;">ToString</span>() + <span style="color: black;">convertTo</span>;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span>}</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="" lang="EN-US"><span style="font-size: small;"><span style=""><span style="color: #000000;"> </span></span><span style="color: blue;">return</span><span style="color: #000000;"> <span style="color: black;">convertTo</span>;</span></span></span></p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="" lang="EN-US"><span style="font-size: small;"><span style="color: #000000;"><span style=""> </span><span style=""></span>}</span></span></span><span style="" lang="EN-US"></span></p>

你可能感兴趣的:(十六进制)