Click here to Skip to main content
15,899,314 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am using the visual studio2008 for c # programming. I am writing a command - console.writeline("this is my first program ");
But not able to see the output when we press the execution button.
Can you please tell me a procedure to see this result on form.
Posted
Updated 23-Feb-11 20:51pm
v2
Comments
Pravin Patil, Mumbai 24-Feb-11 2:51am    
Edited to improve grammar...

There are two possible problems:

1) If you have created this as a console application, then it may be that the application runs too quickly for you to see. Add this line at the end of your Main method:
Console.ReadLine();
This will make the software stop until you have pressed the ENTER key. You should be able to see your text now.

2) If you have created this as a WinForms application, then you need to click on the "output" pane in Visual Studio to see the console output. If you can't find it, look on the menu under "View...Output"



"i think you not fully under stand my main problem. i explain it again. i am a new user i am write a program that print a line (this is my first program); no error in the code.after right the program when i am a press a start debugging button program run and show only a simple small screen."


A question: is the "small window" black, or grey?

If it is black: this is a console application. Make sure your Console.WriteLine instruiction is in the Main method in the file "process.cs"

If it is grey: this is a WinForms application: Discard your Console.WriteLine instruction and open the toolbox (From the menu: "View...Toolbox" under "All Windows Forms" drag a button onto your form.
Double click the button and add the following line to your code when it appears:
MessageBox.Open("Hello Pucit009!");




"i am really very thank full to ans me. you near to my problem my problem is second option. that solution is represent the message box. but i am right only a single statement. just like a (hello its my first program)
simply like print in the java code (hello world)
i want to print in c#. and on the form where is the you ask a add button."


OK: what you want is a Console App.

1) Close your solution (Menu: "File...Close solution")
2) Create a new project (Menu: "File...New Project")
3) In the new project dialog, select "Console Application"
4) Give it a sensible name in the "Name:" text box.
5) Press "OK"

Now if you look in "Program.cs" (double click in the Solution explorer on the RHS of your screen) you will find a method called Main which is pretty empty. Put your Console.WriteLine in there (don't forget the Console.ReadLine() at the end!) and when you run that it will be simple text.
 
Share this answer
 
v3
Comments
Sergey Alexandrovich Kryukov 24-Feb-11 2:52am    
Correct, my 5.
In principle, console with UI is working (not that I recommend it), see my Answer.
--SA
pucit009 24-Feb-11 4:31am    
i think you not fully under stand my main problem. i explain it again. i am a new user i am write a program that print a line (this is my first program); no error in the code.after right the program when i am a press a start debugging button program run and show only a simple small screen.
OriginalGriff 24-Feb-11 4:40am    
Answer updated
pucit009 24-Feb-11 4:49am    
i am really very thank full to ans me. you near to my problem my problem is second option. that solution is represent the message box. but i am right only a single statement. just like a (hello its my first program)
simply like print in the java code (hello world)
i want to print in c#. and on the form where is the you ask a add button.
OriginalGriff 24-Feb-11 4:57am    
Answer updated again
It is ignored if the application is not of console type. There are only two Assembly types: Windows Application, Console Application and Class Library, this is a compiler option; see also project's Properties, Application tab, "Output type".

You can have console if you change the type of your UI application to "Console Applicaion"; then you will have both console and UI. However, there is no need to do that.

To output any text, use controls, such as TextBox. To append text line-by-line, ListBox is convenient. For logging purposes, use System.Diagnostics.EventLog.

As it can be a problem using debugging, you may want to add the following at the end:

cs><br

 
Share this answer
 
v2
Comments
pucit009 24-Feb-11 4:32am    
i think you not fully under stand my main problem. i explain it again. i am a new user i am write a program that print a line (this is my first program); no error in the code.after right the program when i am a press a start debugging button program run and show only a simple small screen.
Sergey Alexandrovich Kryukov 24-Feb-11 13:30pm    
If did not understand only because you did not explain property. You still didn't. Is your "Output type" "Console Application"? If so, you don't see your line, because you don't stop in the debugger where the line is already written. When you just continue from you break point, your application finishes before you notice the text written. You don't really need ReadLine (better yet, ReadKey(true)). But it might make you more comfortable.
--SA
Sergey Alexandrovich Kryukov 24-Feb-11 13:32pm    
See update in the Answer.
--SA
Just add a line Console.ReadKey(); at the end. It will need you press any key before the programme exits.

Hope this helps.
All the best.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900