石之审判 2015-05-20 04:41 采纳率: 100%
浏览 6046
已采纳

使用了未赋值的局部变量。。。可是我明明赋值了呀。。

代码:

string  content = AllFunctions.streamToString(stream, Encoding.UTF8);
            Regex regex = new Regex("\\/song\\?id=[0-9]{5,8}");   //歌曲id
            if (!regex.IsMatch(content))
            {
               return;
            }
            allurls = regex.Matches(content);  //所有匹配项
            random = new Random(Guid.NewGuid().GetHashCode());  //随机数
            index = random.Next(allurls.Count);  //
            listUrl = "http://music.163.com" + allurls[index]; 
            string songID = allurls[index].Value.Split('=')[1];  //在这里赋值的啊!

            musicUrl = "http://music.163.com/api/song/detail/?id=" + songID + "&ids=%5B" + songID + "%5D?csrf_token=" + csrf_token;   //在这里使用就没有错误!!
        getPlaySite: stream = AllFunctions.getOrPostUrl(musicUrl, 0, "", cookie, out outCookie, header, out outHeader, false, null, 0);  //获取歌曲播放链接
            content = AllFunctions.streamToString(stream, Encoding.UTF8);
            string mp3Url = "", songDuration = "";
            try
            {
                ///
            }
                        catch
                        {
                           return;
                        }

            musicUrl = "http://music.163.com/api/log/web?csrf_token=" + csrf_token;  //播放开始和结束的时候需要post的链接
            postData = "action=play&json={\"id\":\"" + songID + "\",\"type\":\"song\"}";

最后一句的时候,提示我songID没赋值,无法编译?
我明明在最前面赋值的了啊,而且前面使用都没有错误,最后一句就说没赋值??

第一次发帖,希望大家帮帮我,谢谢

  • 写回答

4条回答 默认 最新

  • bsdh0606 2015-05-20 04:44
    关注

    是不是跳到getPlaySite分支里没有对songID赋值?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算