Hi all,
I am new to C# and i am learning it from home.. so my doubts may seem silly to some of you:( .
I am posting here to find some help fr the errors i get..

I am practising namespaces and i keep getting this error when i compile it in the DOS mode.
Any help is appreciated.

nov8prac1.cs

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

namespace nov8prac1
{
    class Program
    {
        static void Main()
        {
          //classinprac1 a = new classinprac1 ();
            nov8prac1.classinprac1.classinprac2( );

            Console.WriteLine("Enter you age");
            int age = Convert.ToInt16(Console.ReadLine());
            if (age < 18)
            {
                Console.WriteLine("You may not enter");
                
            }
            else
            {
                Console.WriteLine("Enter your name ");
                string name = Console.ReadLine();
                Console.WriteLine("Welcome {0}", name);
                
            }
        }
    }
}

In the same namespace but in different file i created another class as following:

filename: classinprac1.cs

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


namespace nov8prac1
{
    class classinprac1
    {
        public static void classinprac2( )
        {
            Console.WriteLine("control has come to the class now");
            //Console.WriteLine("return value from the main method to the class is {0}", abc);
        }
    }
}

Errors I am getting in DOS mode are:

error cs0234:The type or namespacename 'classinprac1' does not exist in the namespace 'nov8prac1' (are you missing an assembly reference?)

make it public

public class classinprac1

make it public

public class classinprac1

thankyou for the quick reply.

Had Made it public.
Saved it F5
and
compiled it in the DOS prompt csc nov8prac1.cs

But same error is comming.

One thing i noticed is when i hit f5, the dos window i get is showing no errors and displaying output correctly but when i separetly open DOS window, give file path and compiled it.. it is giving me the above mentioned error again.

what about when you put the class inside the same file?

Try
classinprac1 a = new classinprac1 ();

nov8prac1.a.classinprac2();

what about when you put the class inside the same file?

Successfull execution If I put the class in the same file.

Getting errors if it is put in different file.

Try
classinprac1 a = new classinprac1 ();

nov8prac1.a.classinprac2();

Hi
I tried as above but

getting following error:

Error 1 The type or namespace name 'a' does not exist in the namespace 'nov8prac1' (are you missing an assembly reference?) C:\-----\Visual Studio 2008\Projects\nov8prac1\nov8prac1\nov8prac1.cs 18 23 nov8prac1

I also tried using entire namespace address like:

nov8prac1.classinprac1.classinprac2( );

but getting same error(missing assembly reference error) at runtime.

Beforehand, sorry for my english...
Method classinprac2() declared as static, so to work with him you shouldn't create object of class classinprac1.
This is right:
ov8prac1.classinprac1.classinprac2( );

Beforehand, sorry for my english...
Method classinprac2() declared as static, so to work with him you shouldn't create object of class classinprac1.
This is right:
nov8prac1.classinprac1.classinprac2( );

Hi Antenka,
Thankyou fr responding.

I did try that way too.. but getting same Assembly reference error!

Try type this:
csc nov8prac1.cs classinprac1.cs

or csc *.cs (to include all files in folder)

THANKS A TON ..

now i get no errors.

So does that mean that i was wrong at compilation all this time?!

I had this doubt in mind that how to compile classinprac1.cs file. when i tried to compile this individually it says no entry point i.e., no main method.

Now i know :)

Thanks a lot Antenka.

:) good luck

commented: Nice signature +2

hello actually i read this thread....i know this is old thread now..but i want to ask question to csharplearner ..u dont get any error like:-/ "{ expected". i m usin visual studio 2005...plz reply.....

Error 1 'string' does not contain a definition for 'InitialDirectory' and no extension method 'InitialDirectory' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?) E:\chandra\Addfilestofoldere\Addfilestofoldere\Form1.cs 148 25 Addfilestofoldere

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

namespace Console.ex3
{
    class Program
    {
        static void Main(string[] args)
        {
            int n= 4561;
            Console.WriteLine(n);
            decimal a, b, c; 
            double d1, d2 = 45.123, d3;
             Console.Writeline("d2 value is +d2");
            string S1;
            bool b1 = true;
            Console.WriteLine(" b1");
            string country = "india";
            int states = 28;
            Console.Writeline("our country is" + country + " .it has" + states + "states");
           Console.Read();





        }
    }
}

when i run i got erron message

Error   1   The type or namespace name 'WriteLine' does not exist in the namespace 'Console' (are you missing an assembly reference?)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.