Remove (), RemoveAt (), RemoveRange (), RemoveAll () are the main methods of removing list<t>. Here are a few ways to use and pay attention.
We take list<string> for example
var New list<string"aa" "ba""cc " " DD " " ee " " FF " };
Remove () removes the first item that is matched to the list, the parameter is T in List<t>, the return type is bool, the successful delete returns True, or the return false is not found. For example:
var rt = Strlist.remove ("aa");
Second, RemoveAt () deletes an entry for the specified index. The parameter is int, which represents the index. The return type is void. For example:
Strlist.removeat (0);
RemoveRange () Deletes the entry for the specified index segment, the first parameter is the starting index of the deletion, and the second parameter is the number of deletions. The range type is void. For example:
Strlist.removerange (02);
Iv. RemoveAll () Removes all occurrences of the item, and the parameter is a predicate<t> delegate that defines the condition to be met by the element to be deleted. The return type is int, which indicates the number of deletions. For example:
// Lambda-expression var rt = Strlist.removeall (J=>j.contains ("a")); // Custom Conditions Private Static BOOL Isdel (string str) { return str. Contains ("a");} var rt = Strlist.removeall (Isdel);
C #. Net list<t> The difference between remove (), RemoveAt (), RemoveRange (), RemoveAll (),list<t> Delete Rollup