Firstly the code won't compile as it stands
Firstly, I compiled it in Visual Studio, where I wrote it, and it ran.
this is the simplest app you can write in C#, paste it into a .cs file
created with notepad and once saved, run csc.exe against the file. This
will print out "Hello world".
My point was not to show the OP the simplest code he could write. The point
of the code examples was to illustrate the concept of starting small, and
building up from there. Your criticisms do nothing to clarify the issue at
hand; they simply obfuscate the issue to an admitted beginner.
Programming is all about requirements. The primary requirement which my post
was designed to satisfy was the requirement of assisting the OP with his
question. The requirement I was satisfying with my illustration was to
illustrate the concept of starting small, and building up one's knowledge a
piece at a time.
Anything added to an application, which impedes the satisfaction of the
requirements of an application is not logical. This holds true for
communication as well. Any information which is given in the context of
helping a person to understand an issue he/she has requested information
about, and does not provide further or better understanding regarding that
issue, but instead "muddies the water," is not beneficial, and therefore not
logical.
In other words, the code which I posted was not intended as a primer for
beginning programmers, nor was it presented as such. It was presented as an
illustration of what the proverbial "hello world" example, which the OP
asked about, might look, in order to clarify the reference to it.
Specifically, the entire message was written as an answer to the following
question from the OP:
Do you have a suggested reading on the
"hello world" console app?
From reading the question, I determined that he did not know what I was
referring to when referencing the proverbial "hello world" app. So, I begain
with some explanatory remarks, followed by some illustrative examples, which
served the purpose of clarifying the explanatory remarks. These illustrative
examples were prefaced with this statement:
A console app that writes "hello world" would look something like the
following:
Note the usage of the phrase "something like" in the sentence. This clearly
indicates that the examples to follow were to be illustrative of a concept
(the "hello world" app, which exists in many different forms around the
word), not a tutorial on programming.
Personally, I have better things to do with my time than critique the
responses of others in my attempts to give aid to those who need it. When I
do, it is because there is something in the response that either conveys
incorrect information, or may otherwise be counter-productive to the aid of
the person asking for help. If a response fails to help, or needs further
clarification, I tend to post my own response separately.
As for the critique, I find it lacking in merit. The criticisms are
completely matters of opinion, and are about issues which are not germain to
the issue of helping answer the OP's questions. In some cases, the
criticisms are just plain wrong ("the code won't compile as it stands").
Admittedly, I am in an irritable mood right now, for reasons that are
personal to me. However, I might ask, how does this critique of your
critique make *you* feel?
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
There's a seeker born every minute.
- Dr. "Happy" Harry Cox
"Richard Blewett [DevelopMentor]" <richard at nospam dotnetconsult dot co
dot uk> wrote in message news:%
[email protected]...
namespace ConsoleTest
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
Console.WriteLine("hello world.");
}
}
}
Very simple and straightforward. It does introduce a few concepts, such
as namespaces, classes, the Main() method, Single Threaded Apartment
Threading model, and output.
A couple of things here:
Firstly the code won't compile as it stands - this is the simplest app you
can write in C#, paste it into a .cs file created with notepad and once
saved, run csc.exe against the file. This will print out "Hello world".
class App
{
static void Main()
{
System.Console.WriteLine("Hello world");
}
}
This is as much as anyone needs to get started. And then the rest of your
post is great Kevin about taking it further. We can introduce the using
statement
using System;
class App
{
static void Main()
{
Console.WriteLine("Hello world");
}
}
Note that this means you no longer have to write System.Console and is a
way of saving yourself some typing when you use alot of types from the
same namespace.
Secondly: introducing concepts such as COM apartment threading to someone
just starting out is way too much information and something that is
absolutely not necessary at this stage.
Regards
Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk