|
![](/i/fill.gif) |
>> As for VS, it was a struggle to figure out how to make it compile
>> Hello World and run it. You would have expected this to be the most
>> trivial thing, but no... Given the difficulty of doing this, I didn't
>> exactly hunt around for the button that embeds SkyNet into your program.
>
> In VS C# I can just go to "File -> New Project -> Console Application",
> up pops a "Program.cs" source code file with about 10 lines of code, a
> class containing an empty "Main" method. I write
> "Console.WriteLine("Hello World!");" and press F5. Job done.
As I recall, with VS J++, if you do "console application", it generates
a Java class file with about 30 lines of JavaDoc comment stubs, argument
parsing and exception handling, and so on. (E.g., main() parses the
argument list, and if it sees "--help", it calls a stub method named
help() which you're supposed to fill in.)
Now you could sit there and delete all this crap, or you could select
"empty project". That way, you get to decide what to name your class,
and you can write Hello World quite easily. You then have to configure
VS to know which class is the "main" that you want it to run. (And
whether you want it to run in normal mode or debug mode, and a whole
bunch of other stuff.) And THEN you can actually run it.
Seemed like a whole lot of work, but once you've spent an hour puzzling
out how to do it, it's reasonably easy the next time around.
Oh, and do NOT try to delete or rename classes. VS apparently doesn't
like this at all.
All of this happened a while ago, but my recollection is that when you
remove or rename a source file, the compiled class files hang around,
littering up the place. And trying to figure out where VS stores them is
nontrivial, given that there are normal and debug versions of them. In
the end, I decided that the easiest way to refactor was to create a
brand new, empty project, and import the files from the old project one
at a time. It was just the least painful way to get the job done.
(Again, this seems like a lot of work just to keep VS happy. If I were
just using Notepad and javac, I wouldn't have to do it.)
> Note that as I typed Con the autocomplete list popped up and Console was
> highlighted so I just pressed enter, then when I pressed "." the next
> list popped up of methods/properties of "Console", after I typed "W" it
> highlighted "Write", but then I saw that "WriteLine" was below so I
> pressed down arrow and enter again, then I typed "(" and I was given a
> list of overloaded methods I could call, I just ignored that and entered
> my string, assuming there would be one that took a string. Also if I
> made any mistake (or paused for too long typing before completeing the
> statement) it got underlined in red...
That sounds about right - except, as I say, whenever I pressed enter, it
would move to the next line as well as entering the selected text, so
I'd have to hit backspace to get back to where I was.
Post a reply to this message
|
![](/i/fill.gif) |