Hello World without using VS.NET

  • Thread starter Thread starter Andy Sutorius
  • Start date Start date
A

Andy Sutorius

Has anyone successfully created a Hello World program without using Visual
Studio.NET? If so, what IDE did you use and what namespaces did you import?

Thanks!

Andy Sutorius
 
Step 1: Write the code

public class Hell

public static void Main(

System.Console.WriteLine("Hello, World.")



Step 2: Save and compile

(On command line) csc.exe HelloWorld.c

Step 3: Run it

HelloWorld.ex

Hello, World
 
If you have the .NET SDK installed, you have all the compilers and linkers
and assemblies you need. You can use Notepad or any other text editor to
create and modify the source code, and then use the command line compilers
to create the executables. For instance, key in the following code in
Notepad and save it as Hello.cs. Then from a command window, type
csc Hello.cs
and you'll get Hello.exe. Run Hello.exe and you'll get the hello world
message in a command window.

Here's the code:

using System;

namespace HelloWorldInCSharp
{
class HelloWorldApp
{
static void Main(string[] args)
{
Console.WriteLine("Hello World from C#!");
Console.ReadLine();
}
}
}

The command line compilers and linkers can be used to build any kind of
application or library assembly. There are many command switches. Try csc /?
to get an idea of what's available.

I haven't personally done this since VS.Net was released, so I don't
remember what you need to set up in order to make this work so easily.
Probably some paths need to be set up in the execution environment for the
command window. Look at the SDK documentation to see what needs to be done
by way of environment variables.

If you don't have the .NET SDK, you can get it from the Microsoft site
(without charge, as I understand it).

Good luck,
Tom Dacon
Dacon Software Consulting
 
Wow. Thanks. By chance would you have this same simple app in VB.NET?

Sincerely,

Andy Sutorius
 
Hi Tom,

I have set up the Path, Lib and Include system variables and csc is
compiling quite nicely. However, VB.net is a different story. I am trying to
port over a C# console app to VB.NET but am getting confused with what is
"required" by VB.NET. Statements that VS.NET puts in automatically.
 
Tom Dacon said:
If you have the .NET SDK installed, you have all the compilers and linkers
and assemblies you need.

You don't even need the SDK installed - the .NET framework itself comes
with the C# and VB.NET compilers.
I haven't personally done this since VS.Net was released, so I don't
remember what you need to set up in order to make this work so easily.
Probably some paths need to be set up in the execution environment for the
command window. Look at the SDK documentation to see what needs to be done
by way of environment variables.

Just including the framework directory (eg
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322) on the path is enough.

I use csc all the time - it's much quicker to type in code in a quick
text editor and compile it using csc than it is to wait for VS.NET to
start up, find or create an appropriate solution/project, and then put
the code in, when it comes to quick programs for newsgroup posts, for
instance.
 
Andy Sutorius said:
Wow. Thanks. By chance would you have this same simple app in VB.NET?

Option Strict On

Imports System

Class Test
Shared Sub Main()
Console.WriteLine ("Hello, world")
End Sub
End Class
 
Jon,

Have you tried to compile a vb.net program like you mention using csc
(obviously using vbc)

Thanks,

Andy Sutorius
 
Andy
Jon is not correct re: vbc.exe being installed w/the .NET framework. It does require the .NET SDK (only the C# compiler is installed w/the framework
Once that is install the framework SDK you then need to either
A) Go to the console using the VS 2003 (or 2002) Command Promp
(Start->Programs->VS.NET 2003->VS.NET Tools->VS 2003 Command Prompt
[This is NOT the normal command prompt
-OR
B) Locate Corvars.bat (by default it is @ C:\Program Files\Microsoft Visual Studio .NET\FrameworkSDK\Bin\corvars.ba
and add this location to the Path. (this will allow you to run vbc from any place, and from the "normal" comman
prompt

This proceedure is discribed in Programming Microsoft Visual Basic .NET, MS Press, by Francisco Balena (pp23-24) which I teach from and highly recommend

HTH

Cos Callis, MCAD
 
Andy Sutorius said:
Have you tried to compile a vb.net program like you mention using csc
(obviously using vbc)

Absolutely. Just setting the path is all I needed to do.
 
Cos Callis said:
Andy,
Jon is not correct re: vbc.exe being installed w/the .NET framework.
It does require the .NET SDK (only the C# compiler is installed w/the
framework)

I don't know whether that was true for 1.0 or not, but it's certainly
not true for 1.1.

I've just taken a clean Windows 2000 box and installed the .NET 1.1
Redistributable Package, and I was then able to compile and run the
simple hello world program I previously posted.
 
Hi Andy,

Will you be so kind next time not to multipost (send seperate messages to
different newsgroups)

You have a lot of answers in the VB.language group and Jon could not see
that, when you had sent this to those group in one line with a delimiter
between the addressed newsgroups, Jon would probably not even had taken time
to answer your VB. question.

However he has that ready because that is his sample to show that C# and
VB.net are when compiled almost the same.

:-)

Thanks in advance for the next time,

Cor
 
I just have to throw my 2 cents in here =]

You can also use the eclipse project now, which is open source try google
search to find it, to compile and run C# programs as well as VB.NET
programs. You just need the .NET SDK and so on installed and the appropriate
Eclipse modules. Take a look.

-Evan
 
Back
Top