Al Lelopath
Al Lelopath

Reputation: 6778

Get HttpCookie property

I'm trying to convert the following line from VB to C#:

HttpContext.Current.Request.Cookies("MyCookieName")("MyProperty")

I can get the cookie:

HttpCookie httpCookie = HttpContext.Current.Request.Cookies.Get("MyCookieName");

but don't know how to get the property. Is "property" the correct word for what I am trying to get? How do I get this?

Answer:
string property = HttpContext.Current.Request.Cookies["MyCookieName"]["MyProperty"];

Upvotes: 0

Views: 198

Answers (1)

Trevor Elliott
Trevor Elliott

Reputation: 11252

HttpContext.Current.Request.Cookies["MyCookieName"]["MyProperty"]

That is the equivalent line in C#. Those are indexers.

Upvotes: 2

Related Questions