I have declared a constant variable which is being stored in cookie so its Ok because differnt browser will have a different copy.
private const string CookieName = "TempData";
Now I want to store it at third location where all user data will be stored.
So How can I declare something like
private const string CookieName = "TempData" + DataTime.Now.Tick.tostring(); So that each user will have differnet cookiename stored at third location.
Please advise.
For that you cannot use a const
field. Anything with const
modifier must be able to be evaluated to a constant at compile time.
What you want is a static field initialised by a static constructor
public class YourSurroundingClass {
private static readonly string CookieName;
static YourSurroundingClass() {
CookieName = "TempData" + DateTime.Now.Ticks
.ToString();
}
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments