如何解决此错误:必须在字符串中指定用于解析的有效信息

时间:2018-02-21 10:40:20

标签: c# asp.net .net asp.net-mvc c#-4.0

我想将字符串转换为枚举。我的代码就像这样

   public static string QueryStringParamInitialValue
    {
        get
        {
            string str = string.Empty;
            if (HttpContext.Current != null && HttpContext.Current.Session != null && HttpContext.Current.Session["UIController_QueryStringParamInitialValue"] != null)
                str = HttpContext.Current.Server.UrlDecode(HttpContext.Current.Session["UIController_QueryStringParamInitialValue"] as string);
            return str;
        }
        set
        {
            HttpContext.Current.Session["UIController_QueryStringParamInitialValue"] = (object)HttpContext.Current.Server.UrlEncode(value);
        }
    }

QueryStringParamInitialValue ()就像这样

{{1}}

我在 var categoryEnum =(SiteCategory)Enum.Parse(typeof(SiteCategory),UIController.QueryStringParamInitialValue,true)中遇到错误;

有关这方面的任何信息都会有所帮助。请帮助

1 个答案:

答案 0 :(得分:0)

如果将此错误视为Xamarin项目的一部分:

As mentioned here我必须“在更新后至少启动一次xCode。”让此错误消失。我还必须在xCode更新和启动后重新启动Visual Studio。