I have the following code:
public static void MyFunc(string Title,string Artist,string Music)
{
List<string> g;
if ( !string.IsNullOrEmpty(Title))
{
g.Add( "Title " + " operator " + Title);
}
if ( !string.IsNullOrEmpty(Artist))
{
g.Add("Artist " + " operator " + Artist);
}
if ( !string.IsNullOrEmpty(Music))
{
g.Add("Music " + " operator " + Music);
}
}
I want to avoid repetitive statements (in fact I have more variables (Year, Language,etc) in my real code).
How can I rewrite this code by calling 3 times the same function ?
Is it possible ? Thanks