string 如何在 .net framework 4 中将字符串转换为 base64
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10503061/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do you convert a string into base64 in .net framework 4
提问by Mark Chai
So I've been going around the internet looking for a way to convert regular text(string) into base64 string and found many solutions. I'm trying to use:
所以我一直在互联网上寻找一种将常规文本(字符串)转换为 base64 字符串的方法,并找到了许多解决方案。我正在尝试使用:
Dim byt As Byte() = System.Text.Encoding.UTF8.GetBytes(TextBox1.Text)
TextBox2.Text = convert.ToBase64String(byt)
but it end up with an error saying
但它最终会出现一个错误说
'ToBase64String' is not a member of 'System.Windows.Forms.Timer'.
“ToBase64String”不是“System.Windows.Forms.Timer”的成员。
What do I do to fix this? Or if there's a better way to code it please help.
我该怎么做才能解决这个问题?或者如果有更好的编码方式,请帮忙。
回答by GSerg
Use System.Convert.ToBase64String(byt)
. Otherwise the timer is picked up as the innermost matching name.
Not the best name for a timer btw.
使用System.Convert.ToBase64String(byt)
. 否则,定时器将作为最里面的匹配名称被选取。
顺便说一句,这不是计时器的最佳名称。