title: Force a narrow implicit coercion at compile time
body: <p>I'm trying to define a struct which uses a variable with a restricted range of numbers, and implicit coercion from ints.  I'd like to be able to force build errors if any constants or other hardcoded values are used with this struct.</p>
  
  <p>Here is an example of what I'm trying to accomplish.</p>
  
  <pre><code>    byte a = 123; // Allowed
      byte b = 123123; // Not allowed
      const int x = 123;
      const int y = 123123;
      byte c = x; // Allowed
      byte d = y; // Not allowed
  </code></pre>
  
  <p>I would ideally like to be able to, for example, restrict a number from 1 to 99, so that MyStruct s = 50; works but MyStruct s = 150; causes a compile time error like the bytes b and d above do.</p>
  
  <p>I found <a href="https://stackoverflow.com/questions/32680854/specifying-legal-and-or-illegal-implicits-at-compile-time">something similar for a different language</a>, but not for C#.</p>