編碼: byte[] bytes=Encoding.Default.GetBytes("要轉換的字符串"); Convert.ToBase64String(bytes); 解碼: //"ztKwrsTj"是「我愛你」的base64編碼 byte[] outputb = Convert.FromBase64String("ztKwrsTj"); string orgStr= Encoding.Default.GetString(outputb);