c# - Is it possible to implement property setter explicitly while having a getter publicly available? -


when define interface contains write-only property:

public interface imodulescreendata {     string name { set; } } 

and attempt (naively) implement explicitly intention property have publicly available getter:

public class modulescreen : imodulescreendata {     string imodulescreendata.name { get; set; } } 

then following error:

error 'imodulescreendata.name.get' adds accessor not found in interface member 'imodulescreendata.name'

the error more or less expected, however, after alternative syntax:

public class modulescreen : imodulescreendata {     public string name { get; imodulescreendata.set; } } 

has failed compile, suppose trying not possible. right, or there secret sauce syntax after all?

you can this:

public class modulescreen : imodulescreendata {     string imodulescreendata.name     {         set { name = value; }     }      public string name { get; private set; } } 

on side note, wouldn't recommend set-only properties. method may work better express intention.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -