I have a List in c# in which i am adding list fields.Now while adding i have to check condition,if the condition satisfies then i need to remove the last row added from the
if you need to do it more often , you can even create your own method for pop the last element; something like this:
public void pop(List myList) {
myList.RemoveAt(myList.Count - 1);
}
or even instead of void you can return the value like:
public string pop (List myList) {
// first assign the last value to a seperate string
string extractedString = myList(myList.Count - 1);
// then remove it from list
myList.RemoveAt(myList.Count - 1);
// then return the value
return extractedString;
}
just notice that the second method's return type is not void , it is string b/c we want that function to return us a string ...