Generics C# How to pass a property of a generic object by parameter -


i have created method has problem couldn't sort out.

how can pass parameter predicate? because "x.isactive" , "source.id" , "x.id" vary, objects pass parameter have isactive , id properties.

 public static differences<t> checkchanges<t>(list<t> sourcetable, list<t> destinationtable)     {         var differences = new differences<t>();          foreach (var sourceitem in sourcetable.where(x => x.isactive))         {             var destinationitem = destinationtable.firstordefault(x => x.id == sourceitem.id);         }          return differences;     } 

if can make objects inherit common interface, easier:

public interface iaccount {     int id { get; set; }     bool isactive { get; set; } } 

your method signature more then:

public static differences<iaccount> checkchanges(list<iaccount> sourcetable, list<iaccount> destinationtable) 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -