Avatar ·

How to convert byte[] array to Stream in C#?

Hello everyone! I'm new to C# and .NET, writing a small application for working with images. I have a method that returns a byte array `byte[]` (this is image data retrieved from a database). I need to pass this array to another method that only accepts `System.IO.Stream` (for example, to load into a PictureBox or save to disk). I tried simply assigning the array to a Stream type variable, but the compiler complains about type incompatibility. Here's an example of my code: ```csharp byte[] imageData = GetImageFromDatabase(); // get bytes Stream imageStream = imageData; // Error: Cannot implicitly convert type 'byte[]' to 'System.IO.Stream' ``` How can I correctly convert `byte[]` to `Stream`? Is there some special class or method for this? Thanks in advance.