title: C# Convert T to long
body: <p>I have a generic class (C#),</p>
  
  <pre><code>class MyClass&lt;T&gt; where T : struct, IComparable&lt;T&gt;
  {
      public T filelocation;
  }
  </code></pre>
  
  <p>T can be either UInt32 or UInt64 (nothing else).</p>
  
  <p>I need to convert filelocation to a long to seek in a file...</p>
  
  <p>I have tried the following</p>
  
  <pre><code>long loc = (T)myclass.filelocation;
  
  long loc = (T)(object)myclass.filelocation;
  </code></pre>
  
  <p>But nothing seems to work...</p>
  
  <p>Any ideas?</p>