c# - Fill a boolean array with List that contains indices that must be true -


मान लें कि मेरे पास सूची & lt; int & gt; NullValuesIds युक्त सूचकांक।

मैं NullValuesIds से हैं, और LINQ का उपयोग कर सूचकांक में true असाइन करने वाले एक बूलीयन सरणी को कैसे प्रारंभ कर सकता हूं? (बूलियन सरणी का आकार आकार 100 जैसा होता है)।

  पूर्णांक maxIndex = nullValuesIds.Max (); // या कुछ अन्य अधिकतम var boolArray = संख्यात्मक। रेंज (0, मैक्स इंडैक्स)। चयन करें (NullValuesIds.Contains) .ओएरेरे ();  

यदि प्रदर्शन महत्वपूर्ण है, तो यह बहुत तेजी से होगा यदि NullValuesIds एक हैशसेट और लेफ्टिनेंट; int & gt;


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

c# - Chart control: Design messed Up after clearing and re-adding Y-Values -

ruby on rails - Apipie interferes with proper error codes -