Click here to Skip to main content
15,890,897 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
how to write my output from window application to console


public ClearTripViewModel RoomTypeData()
{
string date = Date();
ClearTripViewModel viewmodel = new ClearTripViewModel();
var days = DateTime.DaysInMonth(Convert.ToInt32(date.Split('/')[1]), Convert.ToInt32(date.Split('/')[0]));
date = _goibService.ChangeDateFormat(date);
if (OverallStaticSession.ClearTripRoomDetails == null)
{
OverallStaticSession.ClearTripRoomDetails = _ctService.GetRoomType(OverallStaticSession.ClearTripHotelId.ToString());
}
var roomlist = OverallStaticSession.ClearTripRoomDetails;
viewmodel.HotelId = OverallStaticSession.ClearTripHotelId.ToString();
var cookie =OverallStaticSession.ClearTripCookie ;
object sync = new Object();
foreach (var items in roomlist)
{
ClearTripRooms obj = new ClearTripRooms();
obj.RoomName = items.value;
obj.RoomTypeId = items.key;
_ctService.GetAvailRooms(viewmodel.HotelId, items.key, date.Split('-')[1], date.Split('-')[0], obj, cookie);
viewmodel.cleartriproom.Add(obj);
}

return viewmodel;

}



MY OUTPUT:

1 2 3 4 5 6 7 8 9 10 11 12 13 15

1 1 1 1 1 1 1 1 1 1 1 1 1 1


In my above method return values in List data.How to display list data in console output from windows form application
Posted
Updated 2-Sep-15 19:58pm
v2
Comments
Member 10918596 3-Sep-15 1:59am    
i am getting output in return view model,i need to write these output to console.HOW?????

Since you are trying to display the items belongs to a list in console, then you have to just execute a loop through the list items and just prints each list items based on their property names.

C#
foreach (var item in viewmodel.cleartriproom)
            {
                Console.WriteLine(item.RoomName + "\t" + item.RoomTypeId);
            }
 
Share this answer
 
Comments
Member 10918596 3-Sep-15 2:58am    
already i used one foreach with return type
Member 10918596 3-Sep-15 5:32am    
nice answer.
 
Share this answer
 
Comments
Member 10918596 3-Sep-15 2:25am    
already saw above example
Member 10918596 3-Sep-15 2:26am    
but this totally Different

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900