26 Replies - 1873 Views - Last Post: 07 April 2012 - 08:36 AM
#1
C# Beginner Question - Blank Console Appearing?
Posted 05 April 2012 - 04:53 PM
I have recently created a C# program (it is a spell checker, but that is unimportant), and I am a little confused about something that is probably very basic, but I cannot figure it out. First I would like to point out that I program in a text editor, not in Visual C# (I like to do everything myself, it helps me learn everything much better).
My program creates a form that the user can interact with, and when I run it from the command prompt by typing "program.exe" my form pops up and everything runs smoothly. However, when I actually click on the icon of program.exe without having a command prompt open, the form launches like usual, but now a blank command prompt launches behind it. Why is this happening? Is there any way to make this not happen?
Thank you very much for any help.
Replies To: C# Beginner Question - Blank Console Appearing?
#2
Re: C# Beginner Question - Blank Console Appearing?
Posted 05 April 2012 - 04:55 PM
Quote
Don't do this, you are only hamstringing yourself for little gain. (In my opinion)
As to your question, show us the code.
#3
Re: C# Beginner Question - Blank Console Appearing?
Posted 05 April 2012 - 05:08 PM
using System;
using System.Windows.Forms;
class WinSkel : Form {
public WinSkel() {
Text = "A Windows Skeleton";
}
[STAThread]
public static void Main() {
WinSkel skel = new WinSkel();
Application.Run(skel);
}
}
As for a text editor, I will probably change to visual studio once I get a better feel for the language, but I am so used to coding in C and C++ in emacs that I find visual studio very daunting. Also I prefer to figure out how everything in C# works from the ground up before I start using an IDE to do things for me.
#4
Re: C# Beginner Question - Blank Console Appearing?
Posted 05 April 2012 - 05:10 PM
#5
Re: C# Beginner Question - Blank Console Appearing?
Posted 05 April 2012 - 05:37 PM
Learn C# the way everyone else does. Then when you have a good understanding of what finished code looks like, how it should be separated and so on, you can delve into the "under the hood" stuff as much as you like. But you will start out with a known good product to dissect.
Like this you don't have a known good product as a starting point. At best you have something that get some kind of results on screen. But it will make your life so hard to learn like this... Then UNLEARN all the bad habits... Only to re-learn the methods, techniques and style that any employer would expect.
Quote
You start by learning a coding language FIRST.
Learn to plan before you type.
THEN you start designing software with a purpose.
Finding answers to specific problems:
If this sounds like you
Newbie/Rookie said:
Otherwise, you can just jump to the resources here:
Some of the tutorials below are for C# or Java not C, C++, VB.NET [...]. But the conceptual stuff of classes, object oriented design, events etc. are not language specific and should give you enough guidance in theory of program development for you to be able to look-up specific code example in your chosen coding language.
Resources, references and suggestions for new programmers. - Updated Mar 2012
This post has been edited by tlhIn`toq: 05 April 2012 - 05:38 PM
#6
Re: C# Beginner Question - Blank Console Appearing?
Posted 05 April 2012 - 05:54 PM
Quote
If it is very simple then what exactly is the solution?
And I'm sorry if you are mad I use a text editor to help learn a language, but having been programming in emacs for years, something feels wrong to me about checking boxes and using drop-down menus to make a form instead of coding it myself. That is not learning the C# programming language, that is learning how to use Visual Studio. I understand they were built to be used together, but they are different. I am very interested in the theory behind programming languages and all of the specific decisions that went into the creation of the language, and I wont learn that by having an IDE create my code for me.
#7
Re: C# Beginner Question - Blank Console Appearing?
Posted 05 April 2012 - 06:16 PM
It doesn't 'feel' right because its not how you did it umpteen years ago. Guess what... Its a whole new cyber world. Whole new languages. Whole new paradigm. Suck it up. You can either fight it, or learn it. It's your choice. I'm not mad. It doesn't affect me either way. I'll still be earning a living at it and Starbucks will still be over priced; no matter what you choose. I just like to see people learn stuff.
As for "I don't learn that way"... Yeah, we hear that now and again.
See FAQ # 24. (Click the SHOW button below)
TOP most asked:
What does this error message mean?
FAQ 2: How do I debug
FAQ 3: How do I make Class1/Form1 talk to Class2/Form2
FAQ (Frequently Asked Questions - Updated Apr 2012
#8
Re: C# Beginner Question - Blank Console Appearing?
Posted 05 April 2012 - 06:33 PM
I am a college junior and a term project of my Concepts of Programming Languages course is to learn C# (everyone gets a different language), write a research paper on the paradigm of the language and what its pros/cons are, and create programs that show off the best features of C#. While coding in C#, I came across this problem and I just would like to know how to fix it (purely for aesthetic reasons other than this weird blank screen, my program runs great). Simply using Visual Studio for this assignment will not help me complete the project. The project is to learn the language. Writing in my paper that I made a windows form by clicking on buttons in Visual Studio will not benefit me. I need to know about the language itself.
#9
Re: C# Beginner Question - Blank Console Appearing?
Posted 05 April 2012 - 06:45 PM
C# in Visual Studio comes with many different project types, WinForms is one example. Another is Console, which is great for learning the core of the C# language without the complications that the UI layer introduces. Want to make a DLL use the Library type.
VS is an incredible and feature packed IDE, which makes it a little intimidating for beginners. Use the C# Express Edition if want to reduce some that. I'm currently using the VS11 Beta on my Desktop and it's amazing (with a few minor issues).
I recommend using VS over Notepad, as the Syntax Highlighting and refactoring tool are vastly superior. Once you experience Intelisense you'll fall in love. VS was developed to aide and improve Developer productive.
Quote
How do know? You haven't try it.
Quote
The best feature is it how interacts with VS (especially the debugger) and rest of the .net framework (family of languages). Or in the case of Windows 8 languages that speak to the WIndows Runtime, .net, Javascript, C++. VS can help you write and debug them inside of one product.
Did you know most of the framework is written in C#?
This post has been edited by AdamSpeight2008: 05 April 2012 - 06:54 PM
#10
Re: C# Beginner Question - Blank Console Appearing?
Posted 05 April 2012 - 06:48 PM
Sure there are DND features, and they are nice for quickly making things line up neatly. Yes you can drag and drop a button from the toolbox to your form. But all that does is produce the code, NOT hide the code. This is what I mean by letting the IDE do some work for you so you have a good example to dissect.
But you can just as easily build your GUI through pure coding within Visual Studio:
void MakeSomeThings()
{
Button btnSend = new Button();
btnSend.Text = "Send";
btnSend.Click += btnSend_Click;
btnSend.Location = new Point(10,10);
btnSend.Name = "btnSend";
Label lblTitle = new Label();
lblTitle.Text = "Well, there ya go";
lblTitle.Location = new Point(10,25);
lblTitle.Name = "lblTitle";
this.Controls.Add(btnSend);
this.Controls.Add(lblTitle);
}
void btnSend_Click(object sender, eventargs e)
{
lblTitle.Text = "Womp! There it is.";
}
I'll use code to build a bunch of controls rather than DND when it makes sense. For example, if I need 25 checkboxes, numerically named and laid in a grid. Heck, its just easer to have it happen in a loop. I'm sure not going to DND 25 of them and name them etc. all by hand.
Quote
If you think that building a program in Visual Studio is all drag-n-drop then it would imply you don't think too highly of those that code it in. You seem to think that you can learn the language as a mere simple side-process of writing your term paper. After all the instruction don't say to learn the language itself, just the paradigms of it. That's a whole 'nother beast of a different color. But you seem to think that learning the language shouldn't be that tough and that you don't even need to use the tools that all the $100,000/year professionals use. Hell... you must be Wiley E. Coyote, Super-Genius.
This post has been edited by tlhIn`toq: 05 April 2012 - 06:50 PM
#11
Re: C# Beginner Question - Blank Console Appearing?
Posted 05 April 2012 - 07:05 PM
#12
Re: C# Beginner Question - Blank Console Appearing?
Posted 05 April 2012 - 07:18 PM
I never said that Visual C# is bad haha. I have done my research and been coding in C# for a few months now, so it is not as if this is my first day (and note that when I started I was using VS). I fully understand the advantages of the .NET (which really has nothing to do with VS, you can still use all the .NET functionality in a text editor), as well as how VS can make huge coding projects much more convenient for the programmer (in terms of organization, among many other concepts). But I am making very small programs (as in programs only one file large haha) so I find making a whole project in VS is simply more than I need for what I am doing (simple file I/O and a basic form interface).
But please help me with my original question, arguing over IDE vs text editors is an age-old debate and is quite off topic - I only included that piece of info so that somebody wouldn't answer "when you make your project choose windows form app instead of console app".
I feel like I am getting better and better at C# everyday, but this one problem I am having is confusing me. I am beginning to think it has less to do with how I coded it and more to do with just the way Windows launches user-made applications, though I am still not sure. Any help on my problem would be greatly appreciated. I personally think it may have something to do with the program thinking its a console app when I want it to be a winform app, but I don't see how you can really target this in the code (besides just making a form vs not making a form/doing console IO). I understand that I probably wouldn't have this problem with VS, but now I am just interested into what VS is doing that is causing this not to happen.
#13
Re: C# Beginner Question - Blank Console Appearing?
Posted 05 April 2012 - 07:24 PM
This post has been edited by AdamSpeight2008: 05 April 2012 - 07:25 PM
#14
Re: C# Beginner Question - Blank Console Appearing?
Posted 05 April 2012 - 07:24 PM
//using statements
namespace ProgramName
{
class Program
{
static void Main()
{
}
}
}
This post has been edited by superkb10: 05 April 2012 - 07:24 PM
#15
Re: C# Beginner Question - Blank Console Appearing?
Posted 05 April 2012 - 07:29 PM
|
|

New Topic/Question
Reply



MultiQuote






|