7.5. 判断字符串是否是有效的cookie的某一项:isValidCookieField


    public bool isValidCookieField(string cookieKey)
    {
        return cookieFieldList.Contains(cookieKey.ToLower());
    }

        

例 7.5. isValidCookieField 的使用范例


    pair.key = ckFieldExpr.Substring(0, equalPos);
    pair.key = pair.key.Trim();
    if (isValidCookieField(pair.key))
    {
        // only process while is valid cookie field
        pair.value = ckFieldExpr.Substring(equalPos + 1);
        pair.value = pair.value.Trim();
        parsedOK = true;
    }