Possible Duplicate:
Why are private fields private to the type, not the instance?
Consider the following code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Test
{
class Program
{
static void Main(string[] args)
{
Foo foo = new Foo();
Foo foo2 = new Foo();
foo.Test(foo);
Console.ReadLine();
}
}
public class Foo
{
public void Test(Foo foo)
{
Console.WriteLine("I was called");
foo.test_fuction();
}
private void test_fuction()
{
Console.WriteLine("!");
}
}
}
In this case, I would expect that the private keyword would prevent the instance's member variables and functions from being accessed. Wouldn't this allow someone to write some poorly written round-about access to some objects? Is there a way to prevent this behaviour? Or is it intended for a good reason?