EncodingInfo.cs 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the MIT license.
  3. // See the LICENSE file in the project root for more information.
  4. namespace System.Text
  5. {
  6. public sealed class EncodingInfo
  7. {
  8. internal EncodingInfo(int codePage, string name, string displayName)
  9. {
  10. CodePage = codePage;
  11. Name = name;
  12. DisplayName = displayName;
  13. }
  14. public int CodePage { get; }
  15. public string Name { get; }
  16. public string DisplayName { get; }
  17. public Encoding GetEncoding()
  18. {
  19. return Encoding.GetEncoding(CodePage);
  20. }
  21. public override bool Equals(object value)
  22. {
  23. EncodingInfo that = value as EncodingInfo;
  24. if (that != null)
  25. {
  26. return this.CodePage == that.CodePage;
  27. }
  28. return false;
  29. }
  30. public override int GetHashCode()
  31. {
  32. return CodePage;
  33. }
  34. }
  35. }