【问题标题】:CS0165 Use of unassigned local variable 'num' line -16CS0165 使用未分配的局部变量 'num' 行 -16
【发布时间】:2022-06-16 23:55:13
【问题描述】:
using System;
using System.Runtime.CompilerServices;
    internal sealed class PrivateImplementationDetails
    {
    internal static uint ComputeStringHash(string s)
    {
        uint num;
        if (s != null)
        {
            num = 2166136261U;
            for (int i = 0; i < s.Length; i++)
            {
                num = (s[i] ^ num) * 16777619U;
            }
        }
        return num;
    }

}

我想构建我的应用程序,但我遇到了这个错误:局部变量 uint num is use of unassigned variable num。

【问题讨论】:

  • 如果s 为空,那么num 将不会被初始化。想要它返回的是s 是空的吗?将 num 初始化为该值。

标签: c# visual-studio


猜你喜欢
  • 2018-12-19
  • 2021-07-22
  • 2019-06-29
  • 2018-07-03
  • 2019-11-08
  • 2013-10-18
  • 2015-11-09
  • 2012-05-18
  • 1970-01-01
相关资源
最近更新 更多