Storage Class

A storage area of Web Storage (https://html.spec.whatwg.org/multipage/webstorage.html#the-storage-interface): window.localStorage or window.sessionStorage. Its items are the items of the storage area of the origin of the document, shared by the documents of the same origin (and, for the session storage, of the same top-level browsing context).

public sealed class Storage

Properties

NameDescription
LengthGets the number of items (https://html.spec.whatwg.org/multipage/webstorage.html#dom-storage-length).

Gets the number of items (https://html.spec.whatwg.org/multipage/webstorage.html#dom-storage-length).

public uint Length { get; }

Methods

NameDescription
Clear()Removes all the items (https://html.spec.whatwg.org/multipage/webstorage.html#dom-storage-clear).
GetItem(string)Returns the value of a key, or null (https://html.spec.whatwg.org/multipage/webstorage.html#dom-storage-getitem).
Key(uint)Returns the key at an index, or null (https://html.spec.whatwg.org/multipage/webstorage.html#dom-storage-key).
RemoveItem(string)Removes a key (https://html.spec.whatwg.org/multipage/webstorage.html#dom-storage-removeitem).
SetItem(string, string)Sets the value of a key (https://html.spec.whatwg.org/multipage/webstorage.html#dom-storage-setitem), and fires a storage event at the other windows that use the storage area. Throws a QuotaExceededError when the quota of the storage area is exceeded.

Clear()

Storage.cs

Removes all the items (https://html.spec.whatwg.org/multipage/webstorage.html#dom-storage-clear).

public void Clear()

GetItem(string)

Storage.cs

Returns the value of a key, or null (https://html.spec.whatwg.org/multipage/webstorage.html#dom-storage-getitem).

public string? GetItem(string key)

Key(uint)

Storage.cs

Returns the key at an index, or null (https://html.spec.whatwg.org/multipage/webstorage.html#dom-storage-key).

public string? Key(uint index)

RemoveItem(string)

Storage.cs

Removes a key (https://html.spec.whatwg.org/multipage/webstorage.html#dom-storage-removeitem).

public void RemoveItem(string key)

SetItem(string, string)

Storage.cs

Sets the value of a key (https://html.spec.whatwg.org/multipage/webstorage.html#dom-storage-setitem), and fires a storage event at the other windows that use the storage area. Throws a QuotaExceededError when the quota of the storage area is exceeded.

public void SetItem(string key, string value)