R
Rajesh
Based on my understanding static members do not have access to non-
static members. In the below example static method 'name' accessing
non-static method creating reference. Seems to me it is not holding to
the theory? Pls explain.
Here is an example:
namespace StaticNonStaticMembers
{
class Program
{
static void Main(string[] args)
{
person p = new person();
System.Console.WriteLine(person.name());
System.Console.WriteLine(p.changename());
}
}
class person
{
public string changename()
{
return "changed";
}
public static string name()
{
person p = new person();
return p.changename();
}
}
}
Thanks.
static members. In the below example static method 'name' accessing
non-static method creating reference. Seems to me it is not holding to
the theory? Pls explain.
Here is an example:
namespace StaticNonStaticMembers
{
class Program
{
static void Main(string[] args)
{
person p = new person();
System.Console.WriteLine(person.name());
System.Console.WriteLine(p.changename());
}
}
class person
{
public string changename()
{
return "changed";
}
public static string name()
{
person p = new person();
return p.changename();
}
}
}
Thanks.