Search code examples
c#arraysarrayofarrays

How to parse some byte arrays in function with "params"?


I have written this function:

    public static Mp3FileReader GetSoundsFromFiles(byte[] bytes)
    {
        return new Mp3FileReader(new MemoryStream(bytes));
    }

And I need to parse some byte arrays with keyword "params" instead of one. Can anyone help me?


Solution

  • Maybe using a list of byte arrays would do the trick for you, like this:

    public static List<Mp3FileReader> GetSoundsFromFiles(List<byte[]> bytes)
    {
        List<Mp3FileReader> soundList=new List<Mp3FileReader>();
        foreach (var a in bytes)
        {
            soundList.Add(new Mp3FileReader(new MemoryStream (a));
        }
        return soundList;
    }