c# instruction switch est de retour approprié pour remplacer pause

Est-ce une façon appropriée de gérer c# instructions de commutation ou explicite d'une pause nécessaire encore? référence

  public static string ToRegistryString(AliceKey.AliceKeyPaths aliceKeyPath)
    {
     switch (aliceKeyPath)
        {
            case AliceKey.AliceKeyPaths.NET_CLR_DATA:
                return @"\.NET CLR Data\";
            case AliceKey.AliceKeyPaths.NET_CLR_NETWORKING:
                return @"\.NET CLR Networking\";
            case AliceKey.AliceKeyPaths.NET_DATA_PROVIDER_MSSQL:
                return @"\.NET Data Provider for SqlServer\";
            case AliceKey.AliceKeyPaths.NET_DATA_PROVIDER_ORACLE:
                return @"\.NET Data Provider for Oracle\";
         }
       return new string(new char[0]);
     }
  • Au lieu de mettre "return new string(new char[0]);" à l'extérieur de l'instruction switch vous pouvez également utiliser le "default: return new string(new char[0]);" l'affaire après tous les autres cas. Ce sera une manière plus propre d'utiliser l'instruction Switch.
InformationsquelleAutor Woot4Moo | 2010-07-07