Fortune.cs 787 B

12345678910111213141516171819202122232425
  1. // Copyright (c) .NET Foundation. All rights reserved.
  2. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
  3. using System;
  4. namespace Benchmarks.Data
  5. {
  6. public readonly struct Fortune : IComparable<Fortune>, IComparable
  7. {
  8. public Fortune(int id, string message)
  9. {
  10. Id = id;
  11. Message = message;
  12. }
  13. public int Id { get; }
  14. public string Message { get; }
  15. public int CompareTo(object obj) => throw new InvalidOperationException("The non-generic CompareTo should not be used");
  16. // Performance critical, using culture insensitive comparison
  17. public int CompareTo(Fortune other) => string.CompareOrdinal(Message, other.Message);
  18. }
  19. }