I wonder if there is any difference between those methods
public bool GetCondition(string s1, string s2)
{
if (s1.StartsWith('a'))
{
return false;
}
if (s2.StartsWith('c'))
{
return false;
}
if (s1.StartsWith('b') && s2.StartsWith('d'))
{
return false;
}
return true;
}
and
public bool GetCondition(string s1, string s2)
{
if (s1.StartsWith('a'))
{
return false;
}
else if (s2.StartsWith('c'))
{
return false;
}
else if (s1.StartsWith('b') && s2.StartsWith('d'))
{
return false;
}
return true;
}
Are they equal or is there a different behaviour to expect? If not, what is the better way to write?
Aucun commentaire:
Enregistrer un commentaire