[C#]Starting off

Skilled Illusionist
Joined
Nov 12, 2007
Messages
333
Reaction score
3
Ok so i want to make this basic Hello world application like this tutorial tells me to.

So i got a few questions.

1. When i open Main.c and click new, do i choose AVR project, Console Application, D application, or Empty project?
2. So i chose Console Application because i have a feeling thats what this is. Then it says C or C++? Well im learning C# so i think i should choose C. Am i right so far?
3. Ok now that i have it open it shows this:

Thesnowman - [C#]Starting off - RaGEZONE Forums

Thesnowman - [C#]Starting off - RaGEZONE Forums


do i delete it or keep it there?

4. If i keep it there and type in the script it tells me to:

Code:
using System.Windows.Form;
using System.Drawing;

Class Myform:Form{
    public static void Main(){
        Application.Run (New MyForm());
    }

    Protected override void OnPain(painteventargs e){
        e.graphics.DrawingString("Hello World!", New Font("Arial", 35),
            Brushes.Blue, 10, 100);
    }
}

So now i have:

Thesnowman - [C#]Starting off - RaGEZONE Forums

Thesnowman - [C#]Starting off - RaGEZONE Forums


5. When i click build i get 8 errors.

Code:
[U][B]File                                                                                                Line           Message[/B]

C:\Users\kyle\Desktop\Programming\Projects\Hello World\main.c     |9|       error: syntax error before "System"|
C:\Users\kyle\Desktop\Programming\Projects\Hello World\main.c    |17|      error: syntax error before "void"|
C:\Users\kyle\Desktop\Programming\Projects\Hello World\main.c    |17|      error: syntax error before "e"|
C:\Users\kyle\Desktop\Programming\Projects\Hello World\main.c     ||In function `OnPain':|
C:\Users\kyle\Desktop\Programming\Projects\Hello World\main.c    |18|      error: `e' undeclared (first use in this function)|
C:\Users\kyle\Desktop\Programming\Projects\Hello World\main.c   |18|       error: (Each undeclared identifier is reported only once|
C:\Users\kyle\Desktop\Programming\Projects\Hello World\main.c   |18|       error: for each function it appears in.)|
C:\Users\kyle\Desktop\Programming\Projects\Hello World\main.c   |18|       error: `New' undeclared (first use in this function)|
C:\Users\kyle\Desktop\Programming\Projects\Hello World\main.c   |18|       error: syntax error before "Font"|
||=== Build finished: 8 errors, 0 warnings ===|

[/U]Can someone tell me what im doing wrong? I don't mean to sound like a noob here but it really sucks when u first start something and you get it wrong right away. The tutorial doesnt tell me where to enter the code, or what to start the project as (Such as Console program or Windows Application or etc..)
 
LMFAO AGAIN! K, sorry. main.c is the name of your file. Basically, your using and old version of a c++ compiler. Yep, you need visual c# 2008. I tried learning c#, but it never really suited me as well as c++, so I won't be able to help you much more after this. Well, I wish you good luck, and hopefully a good laugh when you come back to this a year later.
 
haha yeah thanks, Lol i hate feeling like a noob.

Ok so when i open Microsoft Visual C# 2008 express edition i click File > New Project. Then i click Console Application.

Now there is auto text in it (basically text that appeared when i started the new project).

Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
        }
    }
}

So i just delete it. Then i paste my one C# code for the Hello World! thing. Now it says:

Code:
using System.Windows.Form;
using System.Drawing;

Class Myform:Form{
    public static void Main(){
        Application.Run (New MyForm());
    }

    Protected override void OnPain(painteventargs e){
        e.graphics.DrawingString("Hello World!", New Font("Arial", 35),
            Brushes.Blue, 10, 100);
    }
}

and i get 3 errors stating:

Code:
Error	1	A namespace does not directly contain members such as fields or methods	C:\Users\kyle\AppData\Local\Temporary Projects\ConsoleApplication1\Program.cs	4	1	ConsoleApplication1
Error	2	Expected class, delegate, enum, interface, or struct	C:\Users\kyle\AppData\Local\Temporary Projects\ConsoleApplication1\Program.cs	5	19	ConsoleApplication1
Error	3	Type or namespace definition, or end-of-file expected	C:\Users\kyle\AppData\Local\Temporary Projects\ConsoleApplication1\Program.cs	13	1	ConsoleApplication1

Im so lost... In the tutorial it says nothing about wether its a console or not...

And if i dont delete that first part of the auto code i get more errors. For example.

If i dont delete it, the code is:
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
        }
    }
}
using System.Windows.Form;
using System.Drawing;

Class Myform:Form{
    public static void Main(){
        Application.Run (New MyForm());
    }

    Protected override void OnPain(painteventargs e){
        e.graphics.DrawingString("Hello World!", New Font("Arial", 35),
            Brushes.Blue, 10, 100);
    }
}

And heres the errors i get with it.
Code:
Error	1	A using clause must precede all other elements defined in the namespace except extern alias declarations	C:\Users\kyle\AppData\Local\Temporary Projects\ConsoleApplication1\Program.cs	15	1	ConsoleApplication1
Error	2	A using clause must precede all other elements defined in the namespace except extern alias declarations	C:\Users\kyle\AppData\Local\Temporary Projects\ConsoleApplication1\Program.cs	16	1	ConsoleApplication1
Error	3	A namespace does not directly contain members such as fields or methods	C:\Users\kyle\AppData\Local\Temporary Projects\ConsoleApplication1\Program.cs	18	1	ConsoleApplication1
Error	4	Expected class, delegate, enum, interface, or struct	C:\Users\kyle\AppData\Local\Temporary Projects\ConsoleApplication1\Program.cs	19	19	ConsoleApplication1
Error	5	Type or namespace definition, or end-of-file expected	C:\Users\kyle\AppData\Local\Temporary Projects\ConsoleApplication1\Program.cs	27	1	ConsoleApplication1

So do i leave the first auto part in or do i delete it and post my code?
 
hey, even i didnt know what a netscape or a firefox was at some point xD. It happens to all of us. But hey, it's how we learn
 
lol i didnt know you were going to reply so i edited my post. So any advice?

Even if i go into Start > Microsoft Visual Studio > Visual Studio tools > Visual Studio 2008 command prompt i still get the three errors.

Example.

I clicked Start > Notepad then pasted this code into the document:

Code:
using System.Windows.Form;
using System.Drawing;

Class Myform:Form{
    public static void Main(){
        Application.Run (New MyForm());
    }

    Protected override void OnPain(painteventargs e){
        e.graphics.DrawingString("Hello World!", New Font("Arial", 35),
            Brushes.Blue, 10, 100);
    }
}

and then i save it in C:\ as hellogui.cs

I go back into my VS cmd and change the directory to C:\

i then type in

Code:
csc /target:winexe Hellogui.cs

and i get the same three errors:

Code:
Setting environment for using Microsoft Visual Studio 2008 x86 tools.

C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC>cd C:\

C:\>csc /target:winexe Hellogui.cs
Microsoft (R) Visual C# 2008 Compiler version 3.5.30729.1
for Microsoft (R) .NET Framework version 3.5
Copyright (C) Microsoft Corporation. All rights reserved.
[COLOR="Blue"]
warning CS1668: Invalid search path 'C:\Program Files (x86)\Microsoft Visual
        Studio 9.0\VC\PlatformSDK\lib' specified in 'LIB environment variable'
        -- 'The system cannot find the path specified. '[/COLOR]
[COLOR="Red"]hellogui.cs(4,1): error CS0116: A namespace does not directly contain members
        such as fields or methods
hellogui.cs(5,19): error CS1518: Expected class, delegate, enum, interface, or
        struct
hellogui.cs(13,1): error CS1022: Type or namespace definition, or end-of-file
        expected[/COLOR]

C:\>

The errors are in Red. But you will also notice i put something in blue. How and where do i correct my path from:

Code:
 C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\PlatformSDK\lib

to

Code:
 C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib

please take in mind im on Windows Vista x64 bit
 
lol i didnt know you were going to reply so i edited my post. So any advice?

Even if i go into Start > Microsoft Visual Studio > Visual Studio tools > Visual Studio 2008 command prompt i still get the three errors.

Example.

I clicked Start > Notepad then pasted this code into the document:

Code:
using System.Windows.Form;
using System.Drawing;

Class Myform:Form{
    public static void Main(){
        Application.Run (New MyForm());
    }

    Protected override void OnPain(painteventargs e){
        e.graphics.DrawingString("Hello World!", New Font("Arial", 35),
            Brushes.Blue, 10, 100);
    }
}
and then i save it in C:\ as hellogui.cs

I go back into my VS cmd and change the directory to C:\

i then type in

Code:
csc /target:winexe Hellogui.cs
and i get the same three errors:

Code:
Setting environment for using Microsoft Visual Studio 2008 x86 tools.

C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC>cd C:\

C:\>csc /target:winexe Hellogui.cs
Microsoft (R) Visual C# 2008 Compiler version 3.5.30729.1
for Microsoft (R) .NET Framework version 3.5
Copyright (C) Microsoft Corporation. All rights reserved.
[COLOR=Blue]
warning CS1668: Invalid search path 'C:\Program Files (x86)\Microsoft Visual
        Studio 9.0\VC\PlatformSDK\lib' specified in 'LIB environment variable'
        -- 'The system cannot find the path specified. '[/COLOR]
[COLOR=Red]hellogui.cs(4,1): error CS0116: A namespace does not directly contain members
        such as fields or methods
hellogui.cs(5,19): error CS1518: Expected class, delegate, enum, interface, or
        struct
hellogui.cs(13,1): error CS1022: Type or namespace definition, or end-of-file
        expected[/COLOR]

C:\>
The errors are in Red. But you will also notice i put something in blue. How and where do i correct my path from:

Code:
 C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\PlatformSDK\lib
to

Code:
 C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib
please take in mind im on Windows Vista x64 bit

ok but king i still need to change my path.
 
Back