由于保护级别,无法访问system.linq.strings [英] system.linq.strings is inaccessible due to protection level

查看:135
本文介绍了由于保护级别,无法访问system.linq.strings的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


private byte[] CreateKey(string strPassword)
    {
        //Convert strPassword to an array and store in chrData.
        char[] chrData = strPassword.ToCharArray();
        //Use intLength to get strPassword size.
        int intLength = chrData.GetUpperBound(0);
        //Declare bytDataToHash and make it the same size as chrData.
        byte[] bytDataToHash = new byte[intLength + 1];

        //Use For Next to convert and store chrData into bytDataToHash.
        for (int i = 0; i <= chrData.GetUpperBound(0); i++) {
            bytDataToHash[i] = Convert.ToByte(Strings.Asc(chrData[i]));
        }

推荐答案

类似的声音正在运行.Net网站,而无需确保已安装.Net 3.5.除此之外,更好的方法是这样的:

Sounds like you''re running a .Net website without making sure .Net 3.5 is installed. Beyond that, a better way to do that is like so:

bytDataToHash = Encoding.Unicode.GetBytes(strPassword);



您不需要一次做一个字符.



You don''t need to do it a character at a time.


这篇关于由于保护级别,无法访问system.linq.strings的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆