Results 1 to 8 of 8

Thread: debug.print equivalent for C#

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2003
    Location
    Colorado
    Posts
    10

    Question debug.print equivalent for C#

    Does anybody have any idea on how to do VB's debug.print in C#?

  2. #2

    Thread Starter
    New Member
    Join Date
    Feb 2003
    Location
    Colorado
    Posts
    10
    Nevermind I figured it out.

  3. #3
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    Please provide your answer. This way others who ask the same question can find the answer as well.
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  4. #4

    Thread Starter
    New Member
    Join Date
    Feb 2003
    Location
    Colorado
    Posts
    10

    debug.print equivalent for C# (Resolved)

    Sorry, inlude System.Diagnostics, then use Debug.Write to send output to the debug window, not the immediate window.

  5. #5
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    erm you dont need to use System.Diagnostics , the correct equivalent to Debug.Print in .net / C# is this :
    VB Code:
    1. Console.Write("some stuff!");
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

  6. #6
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    You can use Debug.Print. The out put will be in the debug window.

  7. #7
    New Member
    Join Date
    Sep 2010
    Posts
    1

    Re: debug.print equivalent for C#

    Quote Originally Posted by dynamic_sysop View Post
    erm you dont need to use System.Diagnostics , the correct equivalent to Debug.Print in .net / C# is this :
    VB Code:
    1. Console.Write("some stuff!");
    That's actually not true at all.

    Debug.Print in VB prints to the Immediate Window in VS. Console.Print does not. It either prints to a console if it's a console app or to the output window.

    To be technical, Debug.Print will do TraceInternal.WriteLine which will write to each TraceListener that has been loaded into Listeners.

    Console.Write calls Out.Write which writes to a TextWriter object.

    The correct C# equivalent of VB.Net's Debug.Print is....

    Debug.Print

    And for the record, Debug.Print and Debug.Write are equivalent inasmuch as where they write. Debug.Write just doesn't add the newline character. And they all print to the Immediate Window, which is the same as VB6.

  8. #8
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: debug.print equivalent for C#

    There are a couple of differences between Console methods and Debug methods that haven't been mentioned. If you call Console.WriteLine then the output will be written immediately and in both Debug and Release builds. Debug.WriteLine may not write immediately and any Debug code is not compiled into a Release build. Also, both Debug and Console write to the Output window on my system, which I think is an option somewhere.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width