How can I make a pointer generic in C#?
<p>I have a <code>WriteableBitmap</code> which I use an unsafe method to plot pixels. The essential part looks like this:</p>

<pre><code>private unsafe void DrawBitmap(WriteableBitmap bitmap, byte[] pixels)
{
         // Boilerplate omitted... 

        fixed (byte* pPixels = pixels)
        {
            for (int y = 0; y &lt; height; y++)
            {
                var row = pPixels + (y * width);
                for (int x = 0; x &lt; width; x++)
                {
                    *(row + x) = color[y + height * x];
                }
            }
        }

        bitmap.WritePixels(new Int32Rect(0, 0, width, height), pixels, width*pf.BitsPerPixel/8, 0);
}
</code></pre>

<p>However, it is not certain that what the user wants to plot is of the type <code>byte</code>, and it would make sense to make this method generic (i.e. <code>DrawBitmap&lt;T&gt;</code>) but how can I make the pointer <code>pPixels</code> of type <code>T*</code>?</p>

<p>Is there some other trick that will make my <code>DrawBitmap</code> generic?</p>
