reachin the class' properties from a class define in the former
public class A
{
public A()
{
a=5;
B theb=new B()
}
private int a;
public int thea
{
get{return a;}
set{a=value;}
}
public class B
{
public B();
public int b(int x)
{
//here i need to reach the property of class A
}
}
how can i reach the value of thea property from the method defined inside the B which contained by A?
naura paxPosted Jul 1, 2009, 7:11 AM
I don't think we have exactly a friend equivalent in c#, i'm not sure about internal either.
All you can do is create a an object of class A in your Class B function to access A's property
public class A {
public A() {
a=5; B theb=new B() ;
}
private int a;
public int thea
{
get{return a;}
set{a=value;}
}
public class B
{ public B();
public int b(int x)
{
A a=new A();
a.thea=23;//Whatever you want
//here i need to reach the property of class A
}
}
Please correct me if i'm wrong.