C# - Obsolete only a getter/setter in a property

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nelsonbrodyk
    New Member
    • Mar 2008
    • 81

    C# - Obsolete only a getter/setter in a property

    Hey all,
    Just curious, I want to make the "set" in a property obsolete, but not the get or the property. Is there a way to do this?

    [System.Obsolete]
    Public string FirstName {
    get;
    set;
    }

    works fine, but this fails:

    Public string FirstName {
    get;
    [System.Obsolete]
    set;
    }

    Anyone know of a way to achieve this?
  • ShahbazAshraf
    New Member
    • Mar 2008
    • 36

    #2
    If iam understanding your question correctly then u can use this only for set property ...


    [System.Obsolete]
    public string First_Name
    {
    set
    {
    First_Name = value;
    }
    }

    Comment

    • Plater
      Recognized Expert Expert
      • Apr 2007
      • 7872

      #3
      Would it not be easier to just remove the part you do not want?
      I think people will get the point pretty quick when it doesn't compile.
      Much better then a warning that might be overlooked that says "I'll let you do this, but I'll ignore it" and people be very frustrated as to why things don't work.

      Comment

      • nelsonbrodyk
        New Member
        • Mar 2008
        • 81

        #4
        Originally posted by Plater
        Would it not be easier to just remove the part you do not want?
        I think people will get the point pretty quick when it doesn't compile.
        Much better then a warning that might be overlooked that says "I'll let you do this, but I'll ignore it" and people be very frustrated as to why things don't work.
        While I agree, this is part of a framework, and we have a rule that we only depricate code, we don't remove it in between major revisions. This allows version 1.0 of a client to work on 1.x of the server. In this case, I just want them to stop using the set function of the property, while maintaining the get.

        Comment

        Working...