ASP.NET MVC4: How to convert an IEnumerable to a string for ViewBag
- by sehummel
This is what I'm trying to do, but it doesn't work:
HardwareType hwt = new HardwareType { HType = "PC" };
IEnumerable<Hardware> Pcs = db.Hardware.Where(h => h.HardwareType.Contains(hwt));
ViewBag.Pcs = Pcs.ToString();
So how do I convert my IEnumerable to a string (or other primitive data type) so the compiler won't give me an error…