protected void Page_Load(object sender, EventArgs e)
    {
        string goodInfo=Request.QueryString["goodId"];    }
    bool isHave(string a) { 
        
    }是这样的,我想写一个接收字符串然后存入 cookie
要先看cookie内有没有 id存在,如果已经有了,就不存入,id可能是这样的"1,2,3,4"
如果接收的是"5",就存进去,如果是 有的,就返回FALSE就行
如果没有,拼接进入,在最后加一个","

解决方案 »

  1.   

    string ss=YourCookie;
    string[] Arrss=ss.splite(',');
    List<string> Ls=Arrss.ToList();
    if(Ls.Contains("YourID"))
    {}
    else
    {
    //加入
    }
      

  2.   

    string ss=YourCookie; 
    string[] Arrss=ss.splite(','); 
    List <string> Ls=Arrss.ToList(); 
    if(Ls.Contains("YourID")) 
    {
    //存在 
    return True;} 
    else 

    //不存在return False;
    }手打代码可能有错
      

  3.   


                string a = "1,2,3,4";
                string b = "5";
                if (a.Contains(b))
                {            }
                else
                {
                    a += "," + b;
                }
      

  4.   

    string a="1,2,3,4";
    string b="5"
    if((a+",").Indexof(b+",")!=-1)
    {}
    else
    {
      //add to a
    }
      

  5.   

    我怎么没有ToList这个属性啊,这怎么办