Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Manual debugging "print_r"

Status
Not open for further replies.

skiflyer

Programmer
Joined
Sep 24, 2002
Messages
2,213
Location
US
So, one function I just love in PHP is print_r($variable)... basically what it does is dump the variable to the screen in some easy way to read.... so if you have an array with the values 1 2 3 for example it'd print
Code:
array{
0 => 1
1 => 2
2 => 3
}

And now that I'm getting into C# I'd like to know if I can find something similar to help me along during different steps.

Thanks for any information
 
It doesn't exist in C# -- if you want to dump the contents of an array, you'll need to write a method to do it, and send it over to Console.WriteLine();

Chip H.


____________________________________________________________________
Donate to Katrina relief:
If you want to get the best response to a question, please read FAQ222-2244 first
 
Message Box is a bad idea. Here's Why.

When producing a chunk of code, one of my co-workers would always see if a certain piece of code would be executed by putting in a MessageBox.Show("A$$");

And of course it might show up, it might not. But then he would forget about it. So we were about to release the product to our client when the boss asked to see it. The app threw an exception and DING -> Up came A$$ on the screen.

The boss said A$$? Really? Is this what I want my customer to see?

Don't use MessageBox.Show


As a further note, I personally prefer writing my own message logger. Usually from my App Controller I write:

Appcontroller.GetInstance().WriteDebug("my Message"). I can then choose what I want to do with my message - save it to a file, write it to Console.WriteLine(), etc.
 
Some of us are obviously a bit more professional than your co-worker, JurkMonkey.

[vampire][bat]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top