Method InsertBefore
InsertBefore(T, T)
Inserts the element in the List before the first occurrence of specified element.
Declaration
bool InsertBefore(T pivot, T value)
Parameters
Type | Name | Description |
---|---|---|
T | pivot | Element before which value will be inserted. |
T | value | Element to insert in the List. |
Returns
Type | Description |
---|---|
System.Boolean | False when the value pivot was not found; else true. |
Examples
The following code sample shows how to insert a value before a given pivot in Distributed List.
ICache cache = CacheManager.GetCache("demoClusteredCache");
string dataTypeName = "DistributedList";
IDistributedList<Product> list = cache.DataTypeManager.GetList<Product>(dataTypeName);
// Get new products
Product[] newProducts = new Product[2];
newProducts[0] = new Product { Id = 1, Name = "Chai" };
newProducts[1] = new Product { Id = 2, Name = "Chang" };
newProducts[2] = new Product { Id = 3, Name = "Aniseed Syrup" };
list.InsertBefore(list[5], newProduct);