sums

I am a novice and am not getting what is wrong ( )

I have to use a class across multiple pages(I have made it public)

Whenever I try to reference the functions of the class from other pages, it gives me this error message:

CS0246: The type or namespace name 'myclass' could not be found (are you missing a using directive or an assembly reference )

I tried enclosing it within a namespace(answer).

When, I try to use it in the other pages (in ASP.NET) it gives me the same error message even though I used

using answer;



Re: Visual C# Language Using public classes : error The type or namespace name 'answer' could not be found ]

OmegaMan

Try these steps individually
  • Make sure the object you are using across the boundaries is public.
  • Instead of the using, try pathing out the whole namespace item for example;

namespace abc
{
public myclass {}
}


-----next file

namespace def
{
class GHI
{
abc.myclass theClass = new abc.myclass();
}

}







Re: Visual C# Language Using public classes : error The type or namespace name 'answer' could not be found ]

decyclone

Hi sums,

Just make sure all your definitions of the class are in same namespace (see spelling mistakes). See if you don't miss partial keyword and make all of them public.

If you can not find the solution, just post the code (without inner code, just class definitions) in the following syntax :

File 1 :
namespace Namespace1
{
public partial class Class1 { /* Some Code Here*/ }
}

File 2 :
namespace Namespace1
{
public partial class Class1 { /* Some Code Here*/ }
}

etc...

So, I can analyze any syntax problems in class definition. Using partial definitions causes these kinds of problems when you forget or mistype some syntax in any of the class definitions.