new problem C# friend?

guest31ro

Newcomer
Joined
May 17, 2003
Messages
21
class B;
class A
{
int Func1( B& b ) ;
int Func2( B& b ) ;
};

class B
{
private:
int _b;
friend int A::Func1( B& ); // Grant friend access to one
// function in class B.
};
int A::Func1( B& b ) { return b._b; } // OK: this is a friend.
int A::Func2( B& b ) { return b._b; } // Error: _b is a private member.

I want to declare in C# a function as friend, like up there ....
It is posible, and how?
 
guest31ro said:
I want to acces a function or variable from a class without creating an object of that class.

It sounds to me like you are looking for the static modifier.
Snippet from MSDN

Members of a class are either static members or instance members. Generally speaking, it is useful to think of static members as belonging to classes and instance members as belonging to objects (instances of classes)...
 
Back
Top