I a making a little program that wants to analyse the gender of German nouns in a corpus. For that I have created some methods with a string as return value. For instance, I want to check if there is a definite in front of the noun in the corpus and see if it contains "der", "die" or "das". Deepening on which it returns different values. Like below:
private string definitearticle()
{
// code, where gender is the string which we return - if we can't determine
// the gender it returns "Cannot determine"
return gender;
}
private string indefinitearticle()
{
// code, where gender is the string which we return - if we can't determine
// the gender it returns "Cannot determine"
return gender;
}
I want to loop each one of the methods one by one until I no longer get "Cannot determine" as the return value like below with a list of pointers to the methods (like in Storing a list of methods in C#):
var methods = new List<(System.Action check, string caption)>()
{
(definitearticle, "Definite article"),
(indefinitearticle, "Indefinite article"),
};
foreach (var method in methods)
{
gender = method.check.Invoke();
if (gender != "Cannot determine")
{
// store the outcome that was returned to a list
break;
}
}
The problem is that I do not know how to use a List
with methods
that have a return value
(in this case a string
). Could anyone help me out here?