c# - Making one function instead of two -


i have 2 functions:

public list<string> getallproperties1() {     list<string> output = new list<string>();     foreach (myitem item in getitems())     {         if (!output.contains(item.property1) &&             item.property1 != null)         {             output.add(item.property1);         }     }     return output; }  public list<string> getallproperties2() {     list<string> output = new list<string>();     foreach (myitem item in getitems())     {         if (!output.contains(item.property2) &&             item.property2 != null)         {             output.add(item.property2);         }     }     return output; }     

i renamed functions, items , properties make things more simple. want 1 function, may more simple - instead of these two. how achieve this?

property1 , property 2 both string properties.

do need methods this:

list<string> alluniqueprop1 = getitems()     .select(x => x.property1)     .where(s => s != null)     .distinct()     .tolist(); 

the same property2 , done


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -