Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 26th, 2012  |  syntax: None  |  size: 0.88 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Performance-wise, what would be the expected relative outcome of using struct over class in this list?
  2. internal struct LogEntry
  3. {
  4.     public int ThreadId { get; private set; }
  5.     public DateTime Timestamp { get; private set; }
  6.     public string Message { get; private set; }
  7.  
  8.     public LogEntry(int threadId, DateTime timestamp, string message)
  9.         : this()
  10.     {
  11.         this.ThreadId = threadId;
  12.         this.Timestamp = timestamp;
  13.         this.Message = message ?? string.Empty;
  14.     }
  15. }
  16.        
  17. internal sealed class LogEntry
  18. {
  19.     public int ThreadId { get; private set; }
  20.     public DateTime Timestamp { get; private set; }
  21.     public string Message { get; private set; }
  22.  
  23.     public LogEntry(int threadId, DateTime timestamp, string message)
  24.     {
  25.         this.ThreadId = threadId;
  26.         this.Timestamp = timestamp;
  27.         this.Message = message ?? string.Empty;
  28.     }
  29. }