HttpCookie 构造函数
定义
初始化 HttpCookie 类的新实例。Initializes a new instance of the HttpCookie class.
重载
| HttpCookie(String) |
创建并命名新的 Cookie。Creates and names a new cookie. |
| HttpCookie(String, String) |
创建和命名新的 Cookie,并为其赋值。Creates, names, and assigns a value to a new cookie. |
HttpCookie(String)
创建并命名新的 Cookie。Creates and names a new cookie.
public:
HttpCookie(System::String ^ name);
public HttpCookie (string name);
new System.Web.HttpCookie : string -> System.Web.HttpCookie
Public Sub New (name As String)
参数
- name
- String
新 Cookie 的名称。The name of the new cookie.
示例
下面的代码示例创建一个新 cookie 并为其命名。The following code example creates and names a new cookie.
HttpCookie MyCookie = new HttpCookie("LastVisit");
Dim MyCookie As New HttpCookie("LastVisit")
适用于
HttpCookie(String, String)
创建和命名新的 Cookie,并为其赋值。Creates, names, and assigns a value to a new cookie.
public:
HttpCookie(System::String ^ name, System::String ^ value);
public HttpCookie (string name, string value);
new System.Web.HttpCookie : string * string -> System.Web.HttpCookie
Public Sub New (name As String, value As String)
参数
- name
- String
新 Cookie 的名称。The name of the new cookie.
- value
- String
新 Cookie 的值。The value of the new cookie.
示例
下面的代码示例创建、命名并设置新 cookie 的值。The following code example creates, names, and sets the value of a new cookie.
HttpCookie MyCookie = new HttpCookie("LastVisit",
DateTime.Now.ToString());
Dim MyCookie As New HttpCookie("LastVisit", CStr(DateTime.Now()))