2017-06-29 7 views
0

J'ai utilisé le code ci-dessous dans mon projet. Tout en utilisant cet avertissement FxCop CA1305 se produit.Comment effacer les avertissements FxCop lors de l'utilisation de string.Format (......) dans UWP?

string endtime = string.Format("{0:0000}{1:00}{2:00}T{3:00}{4:00}{5:00}", SchAppointment.EndTime.Year, 
               SchAppointment.EndTime.Month, SchAppointment.EndTime.Day, 
               SchAppointment.EndTime.TimeOfDay.Hours, 
               SchAppointment.EndTime.TimeOfDay.Minutes, 
               SchAppointment.EndTime.TimeOfDay.Seconds); 

Comment puis-je supprimer cet avertissement de mon projet? merci d'avance.

+0

Veuillez partager un [mcve] pouvant reproduire votre problème. Quelle est votre 'SchAppointment.EndTime'? Sans un échantillon complet, nous ne pouvons pas savoir pourquoi vous avez des avertissements. – Scavenger

Répondre

0

Votre code devrait comme ceci:

string endtime = string.Format(
    CultureInfo.CurrentCulture, 
    "{0:0000}{1:00}{2:00}T{3:00}{4:00}{5:00}", 
    SchAppointment.EndTime.Year, 
    SchAppointment.EndTime.Month, 
    SchAppointment.EndTime.Day, 
    SchAppointment.EndTime.TimeOfDay.Hours, 
    SchAppointment.EndTime.TimeOfDay.Minutes, 
    SchAppointment.EndTime.TimeOfDay.Seconds); 

Cela donne la méthode Format des informations pour formater les numéros.