Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- /*Remove не дава грешка, ако го няма елемента
- Contains() връща булев резултат.Те могат да съдържат променливи, не само стойности-Contains(number);*/
- class UsingListRemove
- {
- static void Main()
- {
- int a = 13;
- List<int> list = new List<int>() { 12, 13, 45 };
- if(list.Contains(a))
- {
- list.Remove(a);//по този странен начин ще изтрие 13 и ще останат само 12, 45
- }
- Console.WriteLine(list.Contains(a));//false
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment