IFormatProvider, как правильно реализовать IDisposable - C#

Узнай цену своей работы

Формулировка задачи:

Доброго вам времени суток. Прогоняю свой проект через FxCop(это вообще нужно? или зря?).Исправил все ошибки кроме двух. 1)"Because the behavior of 'int.Parse(string)' could vary based on the current user's locale settings, replace this call in 'PanelSort.ValidIp(object, int, int)' with a call to 'int.Parse(string, IFormatProvider)'. If the result of 'int.Parse(string, IFormatProvider) ' will be displayed to the user, specify 'CultureInfo.CurrentCulture' as the 'IFormatProvider' parameter. Otherwise, if the result will be stored and accessed by software, such as when it is persisted to disk or to a database, specify 'CultureInfo.InvariantCulture'." Help : http://msdn2.microsoft.com/library/ms182190(VS.90).aspx (String) 2)"Implement IDisposable on 'SoundPanel' because it creates members of the following IDisposable types: 'SoundPlayer'." Help : http://msdn2.microsoft.com/library/ms182172(VS.90).aspx (String) Я Help прочитал, суть проблемы уловил в 2 этих ошибках. Но как вызвать int.Parse(string, IFormatProvider)и правильно реализовать IDisposable не могу догнать. Может кто доходчиво объяснить?

Решение задачи: «IFormatProvider, как правильно реализовать IDisposable»

textual
Листинг программы
class Foo : IDisposable
{
   SoundPlayer player;
   public void Dispose()
   {
      if (player != null) player.Dispose();
   }
}

ИИ поможет Вам:


  • решить любую задачу по программированию
  • объяснить код
  • расставить комментарии в коде
  • и т.д
Попробуйте бесплатно

Оцени полезность:

6   голосов , оценка 3.833 из 5
Похожие ответы