I'm using C#, with which I don't have a lot of experience (I've mostly worked with java/php/javascript so far)
What I want is a class in which I save some data, this data can only be written by one other class, but still be read by other classes in the program.
Something like this:
public class DataObtainer{
DataItem[] Items;
public DataObtainer(){
Items = new DataItem[20];
}
public void Update(){
Items[0].SomeProperty = 5;//Being able to change SomeProperty
}
//Class only contains properties
public class DataItem{
public int SomeProperty;
}
}
public class AnyOtherClass{
public void SomeMethod(){
DataObtainer do = new DataObtainer();
//What I want:
DataItem di = do.items[0];
Console.WriteLine(di.SomeProperty);//Being able to read SomeProperty
di.SomeProperty = 5;//Not allow this, not being able to change SomeProperty
}
}