SitePoint Sponsor |
|
User Tag List
Results 1 to 10 of 10
Thread: print_r implementation for .NET
-
Jan 2, 2005, 12:20 #1
- Join Date
- Oct 2002
- Location
- Edinburgh, UK
- Posts
- 1,743
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
print_r implementation for .NET
Code://Copyright 2005 Mike Borozdin class Utils { public static string printR(int[] intArray) { string result = "int[]\n{"; for (int i = 0; i < intArray.Length; i++) { result += "\t[" + i + "] = " + intArray[i] + "\n"; } result += "}"; return result; } public static string printR(string[] stringArray) { string result = "string[]\n{"; for (int i = 0; i < stringArray.Length; i++) { result += "\t[" + i + "] = \"" + stringArray[i] + "\"\n"; } result += "}"; return result; } public static string printR(object[] objArray) { string result = "object[]\n{"; for (int i = 0; i < objArray.Length; i++) { result += "\t[" + i + "] = " + objArray[i] + "\n"; } result += "}"; return result; } public static string printR(ICollection ic) { string result = "Collection\n{"; int i = 0; foreach (object obj in ic) { result += "\t[" + i + "] = " + obj + "\n"; i++; } result += "}"; return result; } public static string printR(IDictionary ic) { string result = "IDictionary\n{"; IDictionaryEnumerator ide = ic.GetEnumerator(); while (ide.MoveNext()) { result += "\t[\"" + ide.Key + "\"] = " + ide.Value + "\n"; } result += "}"; return result; } }
-
Jan 3, 2005, 05:27 #2
- Join Date
- Sep 2000
- Location
- Halmstad, Sweden
- Posts
- 7,400
- Mentioned
- 1 Post(s)
- Tagged
- 0 Thread(s)
Sweeet.
Mattias Johansson
Short, Swedish, Web Developer
Buttons and Dog Tags with your custom design:
FatStatement.com
-
Jan 29, 2005, 12:58 #3
- Join Date
- Aug 2000
- Location
- San Diego, CA
- Posts
- 5,460
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
wht not start the debugger, set a breakpoint, and use quick watch?
Please don't PM me with questions.
Use the forums, that is what they are here for.
-
Jan 30, 2005, 05:11 #4
- Join Date
- Oct 2002
- Location
- Edinburgh, UK
- Posts
- 1,743
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hmmm.... that's an idea, but I noticed people were missing this function and it's not so hard to implement.
-
Sep 15, 2005, 14:35 #5
- Join Date
- Jan 2005
- Location
- Germany
- Posts
- 67
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I'm curious: What's the magic behind this? (I'm not a .NET Developer...)
-
Sep 15, 2005, 16:45 #6
Originally Posted by siteartwork
-
Sep 15, 2005, 17:28 #7
- Join Date
- Jan 2005
- Location
- Germany
- Posts
- 67
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by vgarcia
PHP Code:var_dump()
Didn't know that .NET devs need to implement such a thing in userland, that's why I was irritated at first
-
Sep 15, 2005, 18:19 #8
- Join Date
- May 2003
- Location
- Washington, DC
- Posts
- 10,653
- Mentioned
- 4 Post(s)
- Tagged
- 0 Thread(s)
One need not implement it if you have VS.NET setup since you can watch/trace things. I will admit I have occasionally missed trusty old print_r().
Only thing I would add is that a neater implementation woudl be using recursion & reflection to drill down into complex types, but that could be a real bear.
-
Sep 16, 2005, 05:28 #9
- Join Date
- Sep 2000
- Location
- Halmstad, Sweden
- Posts
- 7,400
- Mentioned
- 1 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by freddydoesphp
Mattias Johansson
Short, Swedish, Web Developer
Buttons and Dog Tags with your custom design:
FatStatement.com
-
Nov 23, 2005, 05:43 #10
- Join Date
- May 2004
- Location
- Netherlands
- Posts
- 219
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by siteartwork
Quaint Tech - Blog on web development and web technology.
Bookmarks