C# List<T> Contains test -


क्या इस तरह का एक-एक आइटम निकालते समय आवश्यक परीक्षण हो?

  if (_items । आइटम (आइटम)) {_items.Remove (आइटम); }  

और, इस परीक्षण के बारे में क्या है?

  यदि (! _items.Contains (आइटम)) {_items.Add (आइटम); }  

आपको निकालने का परीक्षण नहीं करना है निकालें () झूठी बदलेगी यदि वह कुछ भी नहीं निकालता है।

यदि आप अपनी सूची में डुप्लिकेट आइटम नहीं चाहते हैं तो आप जोड़ते समय परीक्षण कर सकते हैं। अन्यथा, आपके पास डुप्लिकेट होंगे।

यह भी देखें:


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -