Results 1 to 9 of 9

Thread: is console.writeline(""); compiled at runtime?

  1. #1

    Thread Starter
    Fanatic Member Crash893's Avatar
    Join Date
    Dec 2005
    Posts
    930

    is console.writeline(""); compiled at runtime?

    I'm not sure if i phrased the question right or not but if i wanted to put in a bunch of console.write commmands in diffrent subs for trouble shooting at debug

    would it be compiled into the runtime exe or is it something that is just for debug?

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

    Re: is console.writeline(""); compiled at runtime?

    Yes it would. Use Debug.Write for debugging. It will not be compiled into a Release build so they can be left in your code permanently without affecting performance.
    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

  3. #3
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,547

    Re: is console.writeline(""); compiled at runtime?

    Well Debug.Write writes to the output window, if you want something to write to the console try this.

    Code:
    [Conditional("DEBUG")]
            static void DebugConsoleWrite(string str)
            {
                Console.Write(str);
            }
            static void Main(string[] args)
            {
                DebugConsoleWrite("hi");
                Console.ReadKey();
            }
    Of if you want to handle it manually from Debug.WriteLine(). You could possibly make a TraceListener. Not sure how though.

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

    Re: is console.writeline(""); compiled at runtime?

    Quote Originally Posted by high6
    Debug.Write writes to the output window
    So does Console.Write while debugging WinForms apps.
    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

  5. #5
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,547

    Re: is console.writeline(""); compiled at runtime?

    Well I meant Debug.Write doesn't output to the console window which is what it sounds like what he wants.

  6. #6

    Thread Starter
    Fanatic Member Crash893's Avatar
    Join Date
    Dec 2005
    Posts
    930

    Re: is console.writeline(""); compiled at runtime?

    Tell me if im crazy

    I am updateing a program that I inherited from someone else.

    I wanted to add console.writeline(Method XXX start); and a matching end to the begining and end of each method in this program

    then run it through a few times doing everything that the program does then see if any of the methods in the program are completely unused.

    this sounds crazy but ive already found 4 that are completely unused. ( It looks like the orginal programer made them then made replacement or updated methods but forgot to delete the older ones)

    but i don't want it to affect the app in terms of speed some im thinking of something i could do.

  7. #7
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051

    Re: is console.writeline(""); compiled at runtime?

    In Visual studio you can right-click on a method and 'Find all references', this could give an indication as to whether it's used (at least from within the current project).
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  8. #8

    Thread Starter
    Fanatic Member Crash893's Avatar
    Join Date
    Dec 2005
    Posts
    930

    Re: is console.writeline(""); compiled at runtime?

    no

    I can find if its refrenced


    but if something is refrenced by something else that isnt used it didn't save me anything

  9. #9
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: is console.writeline(""); compiled at runtime?

    Quote Originally Posted by Crash893
    but if something is refrenced by something else that isnt used it didn't save me anything
    Then... what's the problem?
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

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