title: Override handling for basic/primitive types within a scope
body: <p>I'd like to be able to make code that looks like this:</p>
  
  <pre><code>30, 60, 90
  </code></pre>
  
  <p>And have it make a <code>List&lt;int&gt;</code> with those numbers in it. The problem is that in order to do this I believe I would need to be able to override how an <code>int</code> works within this scope. Is there any way that I could have my own "Int" class that could be used within a specific scope whenever a primitive constant like <code>30</code> was entered? If I'm unable to override <code>int</code> then the class must be used explicitly in this scope I'll end up with something like this:</p>
  
  <pre><code>Int(30),Int(60),Int(90)
  </code></pre>
  
  <p>Which is still less code than the standard way:</p>
  
  <pre><code>var nums = new List&lt;int&gt;(); nums.Add(30); nums.Add(60); nums.Add(90);
  </code></pre>
  
  <p>or even:</p>
  
  <pre><code>var nums = new List&lt;int&gt;{ 30, 60, 90 };
  </code></pre>
  
  <p>I'm playing around with my own scripting language, for education purposes only, not intended for anyone else to use. I'm trying to see how far I can simplify syntax to read closer to a natural language. Is something like in first code block at the top of this question possible? If this is possible, can I extend it to other primitive types?</p>
  
  <p>EDIT: I want something that is pure C#, I'm not doing my own parsing, or writing my own compiler. I'm curious if somehow I can have a primitive type like a constant int be handled through my own type instead? I don't think it's possible, but if not at least StackOverflow is good at giving alternatives I might not have thought about.</p>
  
  <p>Ok, here's what I've come up with so far to get me closer:</p>
  
  <pre><code>public static class Values
  {
      static public List&lt;int&gt; Make(params int[] vals)
      {
          return vals.ToList();
      }
  }
  </code></pre>
  
  <p>This lets me do something like:</p>
  
  <pre><code>var nums = Values.Make(30, 60, 90);
  </code></pre>
  
  <p>Of course, this isn't much shorter than <code>var nums = new List&lt;int&gt;{ 30, 60, 90 };</code> but it lets me abstract the int away so they could also do:</p>
  
  <pre><code>var nums = Values.Make(30.0f, 60.0f, 90.0f);
  </code></pre>
  
  <p>So long as I make a handler for a list of floats. Unfortunately if I make a generic method, like this:</p>
  
  <pre><code>public static List&lt;T&gt; Make&lt;T&gt;(params T[] vals) where T : IComparable&lt;T&gt;
  {
      return vals.ToList();
  }
  </code></pre>
  
  <p>Then it make the syntax of using it longer:</p>
  
  <pre><code>var nums = Values.Make&lt;float&gt;(30.0f, 60.0f, 90.0f);
  </code></pre>