C# - save image as stream : I try to create a screenshot and send it from C# to PHP where I store it.

I create a screenshot like this:

    Bitmap screenshot = TakeScreenshot();
    
Now I try to [save it as a stream][1] so I can send it:

    Stream myStream;  
    screenshot.Save(myStream, System.Drawing.Imaging.ImageFormat.Gif);

However, I get `Use of unassigned local variable 'myStream'`.

What am I doing wrong?

----------


**Functions:**

    private Bitmap TakeScreenshot()
    {
        //Create a new bitmap.
        var bmpScreenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width,
                                       Screen.PrimaryScreen.Bounds.Height,
                                       System.Drawing.Imaging.PixelFormat.Format32bppArgb);
    
        // Create a graphics object from the bitmap.
        using (var gfxScreenshot = Graphics.FromImage(bmpScreenshot))
        {    
            // Take the screenshot from the upper left corner to the right bottom corner.
            gfxScreenshot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X,
                                    Screen.PrimaryScreen.Bounds.Y,
                                    0,
                                    0,
                                    Screen.PrimaryScreen.Bounds.Size,
                                    CopyPixelOperation.SourceCopy);    
        }
    
        return bmpScreenshot;
    }


  [1]: https://msdn.microsoft.com/de-de/library/ms142147(v=vs.110).aspx