if (typeof(List<string>).IsAssignableFrom(ListaServizi.GetType()))
((List<string>)ListaServizi).Sort();
else
{
//... some other solution; there are a few to choose from.
}
也许更为惯用的说法是:
List<string> typeCheck = ListaServizi as List<string>;
if (typeCheck != null)
typeCheck.Sort();
else
{
//... some other solution; there are a few to choose from.
}