I\'m trying to create this generic method to simplify things but I think I messed it up! Can you help with my problem?
This compiles:
private string
You really should not use generics in that case. There are only two options.
So:
string ConcatenateText(Supplier Entity) { ...code...}
string ConcatenateText(Employee Entity) { ...code...}
What you can do is unify both with a base class concentrating all common methods.
Say, if both supplier and employee has Name
:
class BaseClass
{
public string Name {get; set;}
}
class Employee : BaseClass
{
//emplyee stuff except name and other things already in base
}
class Supplier : BaseClass
{
//supplier stuff except name and other things already in base
}
And then, the method takes BaseClass
:
private string ConcatenateText(BaseClass Entity)
{
//code
}