字符串转换成16 进制表示

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _16__进制转换
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = "Hello WorldA";
            char[] values = input.ToCharArray();
            // 字符转换成char 数组
            //数组循环
            foreach (char letter in values)
            {
                int v = Convert.ToInt32(letter);
                //把每个 char 转换成 对应的 数字
                // 转换后是十进制
                //string.Format 将第一个的格式 应用于 第二个。
                // 这个是就是 16 进制的转换
                string hexoutput = string.Format("{0:x}",v);
                Console.WriteLine("转换后 {0}={1}" ,letter ,hexoutput);

            }

            Console.WriteLine();
            Console.ReadKey();
        }
    }
}
/*
1. 把 字符串 变为char 数组
2. 在 有十进制数转换成16 进制数 。
*/
原文地址:https://www.cnblogs.com/gaitian00/p/2606335.html