本文介绍了由于保护级别,无法访问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]));
        }

推荐答案

bytDataToHash = Encoding.Unicode.GetBytes(strPassword);



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



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


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

06-17 11:34