public byte[] GetTasks() { TasksCollection tasks = new TasksCollection(); SQLProvider sqlp = new SQLProvider(); tasks = sqlp.GetAllTasks(); MemoryStream memorystream = new MemoryStream(); BinaryFormatter bf = new BinaryFormatter(); bf.Serialize(memorystream, tasks); memorystream.Flush(); memorystream.Position = 0; byte[] Bytes = memorystream.ToArray(); return(Bytes); }