首页 > 代码库 > C#Winform基础 无符号二进制数(整数)转换为十六进制(小大写版本)

C#Winform基础 无符号二进制数(整数)转换为十六进制(小大写版本)

镇场诗:
———大梦谁觉,水月中建博客。百千磨难,才知世事无常。
———今持佛语,技术无量愿学。愿尽所学,铸一良心博客。
——————————————————————————————————————————

1 UI

技术分享

 

 

 

2 code

 1 using System;
 2 using System.Collections.Generic;
 3 using System.ComponentModel;
 4 using System.Data;
 5 using System.Drawing;
 6 using System.Linq;
 7 using System.Text;
 8 using System.Threading.Tasks;
 9 using System.Windows.Forms;
10 
11 namespace WindowsFormsApplication5
12 {
13     public partial class Form1 : Form
14     {
15         public Form1()
16         {
17             InitializeComponent();
18         }
19 
20         
21         /// <summary>
22         /// 进行进制之间的转换,有缺陷不能进行有符号的进制之间的转换
23         /// </summary>
24         /// <param name="input">被处理的数据</param>
25         /// <param name="typeOfInput">输入的数据是多少进制的</param>
26         /// <param name="typeOfOutput">输出的数据是多少进制的</param>
27         /// <returns>返回转换完成的数据</returns>
28         public string ConvertNumber(string input,int typeOfInput,int typeOfOutput)
29         {
30             int value =http://www.mamicode.com/ Convert.ToInt32(input, typeOfInput);
31             string res = Convert.ToString(value, typeOfOutput);
32 
33             return res;
34         }
35 
36 
37         private void btn2_16_Click(object sender, EventArgs e)
38         {
39             //默认是输出小写,你要是喜欢大写,就用注释掉的这行代码
40             //textBoxOfOutput.Text = ConvertNumber(textBoxOfInput.Text, 2, 16).ToUpper();
41             textBoxOfOutput.Text = ConvertNumber(textBoxOfInput.Text, 2, 16);
42         }
43     }
44 }

 

 

 

 

3 show

技术分享

 

技术分享

 

 

 

 

 

——————————————————————————————————————————
博文的精髓,在技术部分,更在镇场一诗。
C#是优秀的语言,值得努力学习。
如果博文的内容有可以改进的地方,甚至有错误的地方,请留下评论,我一定努力改正,争取铸成一个良心博客。
注:此文仅作为科研学习,如果我无意中侵犯了您的权益,请务必及时告知,我会做出改正。

C#Winform基础 无符号二进制数(整数)转换为十六进制(小大写版本)