PHP Print_r is useful to print out array and dictionary collection. is asp.net build in this function??
You can try:
string[] weekDays4 = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
foreach (var item in weekDays4)
{
Response.Write(item.ToString() + " test<br />");
}
What you are looking for is called "pretty printing". Google ".NET pprint" you might have some luck.
But really, use the debugger.
There's no such function in the framework base class library. If it is for debugging purposes you could set brake points in the code and analyze the values in your collection. If it is for printing it on the screen you could override the ToString method for each object. Yet another option would be to serialize the array to XML if this format is acceptable.
As others have said: you can use the debugger to get a better view if that is what you need. If you want to show the data in the html you can bind the object to a control, which is a much more powerful and flexible way to handle the output.
No there is no function available in .net as print_r(). But you can use your custom function and print array or IEnumerable
items in response. For E.g:
if (val is IEnumerable)
{
var e = val as IEnumerable;
foreach (var i in e)
{
Response.Write(i.ToString() + "<br />");
}
}
You can achieve it by JavaScriptSerializer
var json = new JavaScriptSerializer().Serialize(yourObject);
Response.Write("yourObject:" + json + "<br/>");