how to use for loop in Implicitly Typed Arrays using c#in below code.i need to loop through roomList in forloop in dynamic.already i created one list also
List:
public class Inventory
{
public Inventory()
{
roomlist = new List<roomtariff>();
}
public List<roomtariff> roomlist { get; set; }
}
public class RoomTariff
{
public string tarifSeq { get; set; }
public string roomSeq { get; set; }
public string tariffType { get; set; }
public string roomType { get; set; }
public string plan { get; set; }
}
My code
for (int i = 0; i < child[0].roomlist.Count; i++)
{
var postdata = new
{
fromDate = fromdate,
toDate = todate,
hotelRequest = new
{
roomList = new[]
{
new { roomSeq = "54545", roomName = "A.c Room", tariffRequests = new[] { new { tarifSeq = "dfdf45b54", plan = "yu" } } },
new { roomSeq = "5454", roomName = "Del Room", tariffRequests = new[] { new { tarifSeq = "gdgfdg;l;gfd", plan = "Eu" } } },
new { roomSeq = "5422", roomName = "Suite Room", tariffRequests = new[] { new { tarifSeq = "fdght411", plan = "Euuu" } } },
new { roomSeq = "457", roomName = "Execu Room", tariffRequests = new[] { new { tarifSeq = "gfgfgf", plan = "tyt" } } },
new { roomSeq = "222", roomName = "NonRoom", tariffRequests = new[] { new { tarifSeq = "gfgfg", plan = "tyty" } } } }
},
datavisible = false
};
string requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(postdata);