how to store types as variables and use them in parameters' type?
<pre><code>class constType
{
    public static const Type messageType = typeof(int); // HOW TO DO THIS? 1st mark

    public string[] GetArraySomehow()
    {
        return new string[sizeof(messageType)]; // HOW TO DO THIS? 2nd mark
    }
}

class testTypeInClass
{
    public void test(constType.messageType message) // HOW TO DO THIS? 3rd mark
    {

    }
}
</code></pre>

<p>Okay so this is really weird and strange I know but how can I do this?</p>

<ul>
<li><strong>1st mark:</strong> I have to store int's type as const variable and use it laterç</li>
<li><strong>2nd mark:</strong> I have to get stored type's size (how many bytes does it equal?)</li>
<li><strong>3rd mark:</strong> I have to use it as a parameter type.</li>
</ul>

<p>Well Why I have to do this such thing:</p>

<p>I have to store a type (not so wide, just I know I'll use int8,16,32 etc)
and have to know what exactly bytes does it equal (1,2,4 etc..);</p>

<p>well first of all I have a method in one of my classes which uses switch statement and:</p>

<p>like this:</p>

<pre><code>  public string test (int messageIndex)
    {
        switch (messageIndex)
        {
            case 0:
                return "etc.. etc..";
            case 1231412:
                return "whatever";
        }
    }
</code></pre>

<p>Firstly I had some method like this:</p>

<pre><code>public int fixForSwitchStatement(byte[] messageIndex)
    {
        byte[] RValue = new byte[4];

        for (int i = 0; i &lt;= messageIndex.Length - 1; i++)
        {
            RValue[i] = messageIndex[i];
        }
        for (int i = messageIndex.Length; i &lt;= 4 - messageIndex.Length - 1; i++)
        {
            RValue[i] = 0;
        }

        return BitConverter.ToInt32(RValue, 0);
    }
</code></pre>

<p>I was passing byte or short to switch statement then I was converting to int (int was a specified type for me) and I wanted to make a redesign like this.</p>

<pre><code>public string test (/* [what's the case limit? that I've determined?] */ messageIndex)
    {
        switch (messageIndex)
        {
            case 0:
                return "etc.. etc..";
            case 1231412:
                return "whatever";
        }
    }
</code></pre>

<p>Because I don't want to use fixSwitch... method anymore. I just need a specified type for all of these concept.</p>

<p>Why I have to use fixSwitch instead of typecasting like (int)somethingByte?</p>

<p>Well in my one of classes there is a thing called communicationSize, its the messageIndex thing's maximum size in byte(s) that I have to declare. This is for my server-client project. There is a messageIndex thing being used as a request index what server and client requests from each other. And I'm limiting it with byte(s). For save some data space from connection.</p>

<pre><code>// still is being written
</code></pre>
