473,830 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

System.Console. WriteLine question

Hi Newsgroupies,

I'm writing a Web Forms program using C# (VS.NET 2003) and trying to
monitor it whilst running using "System.Console .WriteLine(<par ams>)" but
can't for the life of me find where it outputs too.

Am I thick or just unlucky?

Please help!

Lost & Bewildered, UK

Ps: Back in the good old days we had something called "TRACE" ;-)
Nov 16 '05
12 3793
How do I do the C# equivalent of the MFC code...

int iNumber = 34;

TRACE("The answer is %04d\n", iNumber);

"The answer is 0034"

....i.e. pad the number out with leading spaces? What do I have to add to
this in C#...

System.Diagnost ics.Trace.Write Line( String.Format( "{0}",
iNumber.ToStrin g() ) );

Thanks again,

Newsgroupie

In message <MP************ ************@ms news.microsoft. com>, Jon Skeet
<?@pobox.com.in valid> writes
newsgroupie <ne*********@no spam.com> wrote:
Hi Newsgroupies!

Thanks for all your help but what I really want to do is something like
we could do in the good old days with MFC, ie...

TRACE("The function returned %d\n", iReturnValue);

...And be able to see this in the output window.

I appreciate that .Debug & .Trace do a similar thing in C# but without
arguments as above.


So call String.Format yourself:

String.Forma t ("The function returned {0}", returnValue);

and pass that in as the single argument.

Nov 16 '05 #11
newsgroupie <ne*********@no spam.com> wrote:
How do I do the C# equivalent of the MFC code...

int iNumber = 34;

TRACE("The answer is %04d\n", iNumber);

"The answer is 0034"

...i.e. pad the number out with leading spaces? What do I have to add to
this in C#...

System.Diagnost ics.Trace.Write Line( String.Format( "{0}",
iNumber.ToStrin g() ) );


Use String.Format ("{0:d4}", iNumber)

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #12
newsgroupie <ne*********@no spam.com> wrote:
How do I do the C# equivalent of the MFC code...

int iNumber = 34;

TRACE("The answer is %04d\n", iNumber);

"The answer is 0034"

...i.e. pad the number out with leading spaces? What do I have to add to
this in C#...

System.Diagnost ics.Trace.Write Line( String.Format( "{0}",
iNumber.ToStrin g() ) );


Use String.Format ("{0:d4}", iNumber)

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
12053
by: Abraham Lopez | last post by:
Hi.. Is there a way to convert a System.Array to XML... If you know thanks very much... if you don't... Please do not respond stupid things like " Yes -- many ways."
1
17142
by: Martin Honnen | last post by:
With both .NET 1.0 and 1.1 I have found the following strange behaviour where System.Xml.XmlDocument.LoadXml doesn't throw an error when parsing a text node with a character reference to an invalid characters like &#x1;. Using the CreateTextNode method I create a text node containing "\u0001a" (C# string literal notation). As far as I understand the DOM allows that and an implementation is not required to throw an error. When OuterXml is...
4
3856
by: William McIlroy | last post by:
Array Bounds Exception inside system.xml.dll. Test data is a dozen GB (available for the asking on CD). Source code follows. Call into system.xml.dll happens at the while statement.. using System using System.Xml using System.Collections // This program reads an ASCII file of XML elements // The output is a list of unique NODE TYPEs // For example, <head> produces head in the output // There is no validation of the XML
9
16566
by: Tylius | last post by:
This one line is causing the issue, I've searched all over the net, but I can't seem to figure out why public static void Main(string args) { Console.WriteLine("Dice Roller"); try { int num_dice = int.Parse(args); // This is the problem
5
6600
by: Deiussum | last post by:
I'm running into an issue where I have a timer that appears to be timing out immediately, when it shouldn't be timing out for about int.MaxValue milliseconds. I have written a small app that isolates the problem and was wondering if anyone had any ideas on what I am doing wrong, or if there is some known bug, or I am exceeding some known maximum (which I can't seen to find in documentation anywhere...) Anyway, the following code used to...
6
10222
by: Don | last post by:
I'm having problems working with a streamwriter object. After closing the streamwriter and setting it to Nothing, I try to delete the file it was writing to, but I always get the following error message: "The process cannot access the file "whatever" because it is being used by another process." I've even tried opening another file using the same streamwriter object before deleting the original file, but it's no use. Something keeps...
20
1487
by: djc | last post by:
I get this *intermittently* on a utility I am working on. I don't know whats going on but here are a few points about it: - using VS 2005, running on xp sp2 - program uses multiple threadpool threads - only happens when built with the 'release' configuration (no debug flag, compiler optimizations in effect) - no problems in debug config here is the error: Unhandled Exception: System.AccessViolationException: Attempted to read or write...
1
2444
by: =?Utf-8?B?QnJpYW4gQ29iYg==?= | last post by:
This code is contained in one source file in VS 2005 project: using System; using System.Collections.Generic; using System.Text; using System.Reflection; namespace ReflectionTest { internal class x
1
4606
by: nygiantswin2005 | last post by:
Hi I am trying to resolve this bug that I have in this application. The code is below. It will generate this Exception System.UnauthorizedAccessException: Access to the path is denied. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.__Error.WinIOError() at System.IO.FileInfo.MoveTo(String destFileName)
0
9790
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10770
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10481
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10524
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10199
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6948
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5779
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4409
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3074
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.