dimanche 7 août 2016

Obtain a reference to a property in C# and assign this to another property

If I have

public class ClassA
{
    public static IEnumerable<string> WhateverA { get; set; }
}

and also

public class ClassB
{
    public static IEnumerable<string> WhateverB { get; set; }
}

Is it possible to obtain a reference to ClassA.WhateverA and assign it to ClassB.WhateverB such that if WhateverA is later assigned a value, WhateverB will consequently be assigned the same?

If I was looking to do the same with methods then I could declare WhateverB as an Action and then assign WhateverA as a delegate, thus giving it a kind of 'pass-through' capability. Is it possible to do the same with a property such that WhataverB always shows the value of WhateverA?





Aucun commentaire:

Enregistrer un commentaire