ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Check item Exists in List Item in Console Application using C#<p>Your provided code is not correct there are some build error. Refer the below sample code. Also the property with the name is not correct if you need to pass the string value in class object then you just need one string variable and need to add that variable each time in List of the class object not in single object. also for to check true/false condition you just need to specify only one Boolean property not need to use two different property just set it as true when you need to check is filter value exist set it to false when filter value need to exclude from the checking.</p> <p>Refer the below sample code for your reference and implement it as per your code logic.</p> <p><span style="text-decoration: underline;"><strong>C#</strong></span> </p> <pre class="brush: csharp">class Program { class Filter { /// &lt;summary&gt; /// ItemValue /// &lt;/summary&gt; public string ItemValue; } ///&lt;summary&gt; /// Gets or set whether this filter includes the added values. /// /// Defaults to false /// &lt;/summary&gt; public static bool FilterIncludes; static Filter AddFilterObject(string value) { Filter filter = new Filter(); filter.ItemValue = value; return filter; } static void RunFilterDriver() { List&lt;Filter&gt; ListFilter = new List&lt;Filter&gt;(); ListFilter.Add(AddFilterObject(&#34;vanilla&#34;)); ListFilter.Add(AddFilterObject(&#34;Mint&#34;)); FilterIncludes = true; FilterTest(&#34;vanilla&#34;, ListFilter); //true FilterTest(&#34;red velvet&#34;, ListFilter); //false FilterTest(&#34;Mint&#34;, ListFilter); //true FilterIncludes = false; FilterTest(&#34;vanilla&#34;, ListFilter); //false FilterTest(&#34;red velvet&#34;, ListFilter); //true FilterTest(&#34;Mint&#34;, ListFilter); //false } static void FilterTest(string value, List&lt;Filter&gt; ListFilter) { bool IncludeorExclude = false; foreach (Filter item in ListFilter) { if (item.ItemValue.ToUpper() == value.ToUpper()) { IncludeorExclude = FilterIncludes; break; } else { IncludeorExclude = !FilterIncludes; } } string IncludedOrExcuded = IncludeorExclude ? &#34;True&#34; : &#34;False&#34;; Console.WriteLine(value + &#34; -- &#34; + IncludedOrExcuded); } static void Main(string[] args) { RunFilterDriver(); Console.ReadLine(); } }</pre> <p><span style="text-decoration: underline;"><strong>Screenshot</strong></span></p> <p><span style="text-decoration: underline;"><strong><img src="https://i.imgur.com/fOP83rN.jpg" alt="" width="472" height="153" /></strong></span></p>https://www.aspforums.net:443/Threads/332090/Check-item-Exists-in-List-Item-in-Console-Application-using-C/https://www.aspforums.net:443/Threads/332090/Check-item-Exists-in-List-Item-in-Console-Application-using-C/Wed, 20 Dec 2017 00:37:07 GMT