C# Base64解码:将Base64字符串转换为字符串
可以使用System.Convert类的FromBase64String方法将Base64字符串转换为字节数组,然后使用Encoding类的GetString方法将字节数组转换为字符串。
示例代码:
using System;
using System.Text;
class Program
{
static void Main()
{
string base64String = 'SGVsbG8gV29ybGQh'; // Base64编码的字符串
byte[] bytes = Convert.FromBase64String(base64String); // 将Base64字符串转换为字节数组
string decodedString = Encoding.UTF8.GetString(bytes); // 将字节数组转换为字符串
Console.WriteLine(decodedString); // 输出解码后的字符串
}
}
输出结果:
Hello World!
原文地址: https://www.cveoy.top/t/topic/oiiB 著作权归作者所有。请勿转载和采集!