I use splice() function in JavaScript.
I couldn't find an equivalent method for ASP.NET. Is there any?
If not, how can I insert or remove an index of an array in ASP.NET?
I am trying to use the logic of this JavaScript code I've written once. Trying to do the same with ASP.NET, if that would help.
var imagePath = "/ImageFolder/Gallery/AnAlbum/image.jpg";
var folders = imagePath.split("/");
var imageFile = folders[folders.length - 1];
folders.splice(folders.length - 1, 1);
var newPath = folders.join("/");
var newImageUrl = newPath + "/thumb/thumb_" + imageFile;
return newImageUrl;
EDIT:
What is Splice?
From.
array.splice(start, deleteCount[, item1[, item2[, ...]]])
Parameters
start
Index at which to start changing the array. If greater than the length of the array, actual starting index will be set to the length of the array. If negative, will begin that many elements from the end.
deleteCount
An integer indicating the number of old array elements to remove. If deleteCount is 0, no elements are removed. In this case, you should specify at least one new element. If deleteCount is greater than the number of elements left in the array starting at start, then all of the elements through the end of the array will be deleted.
itemN
The element to add to the array. If you don't specify any elements, splice() will only remove elements from the array.
Returns
An array containing the deleted elements. If only one element is removed, an array of one element is returned. If no elements are removed, an empty array is returned.
Expected Output:
/ImageFolder/Gallery/AnAlbum/image.jpg
/ImageFolder/Gallery/AnAlbum/thumb/thumb_image.jpg