Hello i want to be able to set the a of a field of an object only in an extension
method. I would want that this field to either be completelely private , or be just get
-able from outside:
public class Myclass
{
private int Value{get;set;}
}
public static class Ext
{
public Myclass SetValue(this Myclass obj,int val)
{
this.obj.Value=val;
return obj;
}
}
As you can see in the above example , i have to declare Value
public to be able to access it inside the extension , i would be ok with that if i could make the variable only get-able
from outside.
I need this functionality because i want to develop something like a fluent
api , where you can only set some variables using the extension.
ex:
a=new Myclass();
a.SetValue1(1).SetValue2(2);//--some code //--a.SetValue3(3);