partical classes

S

suspended

In my ASP .NET application, I have two partial classes A and B that
belong to the same namespace "DataBank". I need to manipulate an object
in class A from within class B. Since partial classes cannot be
accessed through the namespace, how can I access the variables of one
class from the other?

Thanks.
Jessica
 
S

sdbillsfan

Why can't partial classes be acccessed through the namespace? "Partial
classes" are no different then any other class, their code just happens
to be divided up into more than one file. What problem are you seeing?
 
S

suspended

Can you please post some code where one partial class calls a method in
another?

Thanks.
Jessica
 
T

Tom Spink

Can you please post some code where one partial class calls a method in
another?

Thanks.
Jessica

Source File 1:
///
public partial class A
{
void foo()
{
bar();
}
}
///

Source File 2:
///
public partial class A
{
void bar()
{
Console.WriteLine( "foobar" );
}
}
///

There's a partial class called 'A', with a method foo() that calls the
method bar(), also defined in the other part of class 'A'.

Is this what you mean?
 
J

Jessica Weiner

Tom Spink said:
There's a partial class called 'A', with a method foo() that calls the
method bar(), also defined in the other part of class 'A'.

Is this what you mean?

No, I mean to do something like this:

Source File 1:

namespace DataLink
{
public partial class A
{
public static string string_a; // global
}
}


Source File 2:

namespace DataLink
{
public partial class B
{
public B( )
{
DataLink.A.string_a = "hello world";
}
}
}


Thanks
Jess
 
T

Tom Spink

Jessica said:
No, I mean to do something like this:

Source File 1:

namespace DataLink
{
public partial class A
{
public static string string_a; // global
}
}


Source File 2:

namespace DataLink
{
public partial class B
{
public B( )
{
DataLink.A.string_a = "hello world";
}
}
}


Thanks
Jess

Hi Jess,

Is this not working for you? It's fine for me, and apparently Jon. Do you
get compile errors?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top