"not accessible in this context because it is protected"

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • eBob.com

    "not accessible in this context because it is protected"

    I'm getting this error on this statement ...

    Dim TA_rect As Rectangle = CType(Me.Client Rectangle.membe rwiseclone(),
    Rectangle)

    "Me" inherits from UserControl.

    I'm not an OOD guru but maybe I sort of understand the problem. If so, this
    is not my fault, right? Since I can access ClientRectangle I don't see why
    I can't clone it. Is there anything easier/better than typing out all of
    the code to make a field by field copy?

    Thanks, Bob


  • Jack Jackson

    #2
    Re: "not accessible in this context because it is protected"

    On Sun, 28 Sep 2008 17:16:25 -0400, "eBob.com"
    <eBob.com@total lybogus.comwrot e:
    >I'm getting this error on this statement ...
    >
    >Dim TA_rect As Rectangle = CType(Me.Client Rectangle.membe rwiseclone(),
    >Rectangle)
    >
    >"Me" inherits from UserControl.
    >
    >I'm not an OOD guru but maybe I sort of understand the problem. If so, this
    >is not my fault, right? Since I can access ClientRectangle I don't see why
    >I can't clone it. Is there anything easier/better than typing out all of
    >the code to make a field by field copy?
    >
    >Thanks, Bob
    >
    Dim TA_rect As Rectangle = Me.ClientRectan gle

    You get an error because Rectangle hides the MemberwiseClone method,
    probably because it is unnecessary since Rectangle is a Value type.

    Because Rectangle is a Value type the above statement will make a copy
    since Value types are copied on assignment.

    Comment

    • eBob.com

      #3
      Re: &quot;not accessible in this context because it is protected&quot;


      "Jack Jackson" <jjackson@cinno vations.netwrot e in message
      news:a6a0e4lq3m ep96saoku153ehk egka0teaj@4ax.c om...
      On Sun, 28 Sep 2008 17:16:25 -0400, "eBob.com"
      <eBob.com@total lybogus.comwrot e:
      >
      >>I'm getting this error on this statement ...
      >>
      >>Dim TA_rect As Rectangle = CType(Me.Client Rectangle.membe rwiseclone(),
      >>Rectangle)
      >>
      >>"Me" inherits from UserControl.
      >>
      >>I'm not an OOD guru but maybe I sort of understand the problem. If so,
      >>this
      >>is not my fault, right? Since I can access ClientRectangle I don't see
      >>why
      >>I can't clone it. Is there anything easier/better than typing out all of
      >>the code to make a field by field copy?
      >>
      >>Thanks, Bob
      >>
      >
      Dim TA_rect As Rectangle = Me.ClientRectan gle
      >
      You get an error because Rectangle hides the MemberwiseClone method,
      probably because it is unnecessary since Rectangle is a Value type.
      >
      Because Rectangle is a Value type the above statement will make a copy
      since Value types are copied on assignment.
      Thank you VERY much Jack. I went back to take another look at the Rectangle
      doc and it certainly makes no secret of the fact that Rectangle is a
      Structure and not a Class. I don't know if I didn't see that or if the
      implication just didn't register.

      BUT ... this problem caused me to do some research and thinking and I'd
      appreciate your comments, or anyone elses, on what I think I have learned.
      In general, in OOP, as the coder of an app, as opposed to the coder of a
      class, this area of creating a copy of an object is, I think the technical
      term is, mess! In general the case X=Y where Y is a Structure looks
      straightforward , but if elements of Y are references then you don't really
      end up with a complete copy. Right? The elements within Y better be value
      types or other Structures consisting only of value types, etc.. So you
      really have to know what your are working with when you need to make a copy
      of it. (Of course it's always been the case in programming that you really
      have to know what you are doing, but that is easier in some cases than in
      others.)

      Thanks, Bob


      Comment

      • Jack Jackson

        #4
        Re: &quot;not accessible in this context because it is protected&quot;

        On Mon, 29 Sep 2008 11:51:06 -0400, "eBob.com"
        <eBob.com@total lybogus.comwrot e:
        >
        >"Jack Jackson" <jjackson@cinno vations.netwrot e in message
        >news:a6a0e4lq3 mep96saoku153eh kegka0teaj@4ax. com...
        >On Sun, 28 Sep 2008 17:16:25 -0400, "eBob.com"
        ><eBob.com@tota llybogus.comwro te:
        >>
        >>>I'm getting this error on this statement ...
        >>>
        >>>Dim TA_rect As Rectangle = CType(Me.Client Rectangle.membe rwiseclone(),
        >>>Rectangle)
        >>>
        >>>"Me" inherits from UserControl.
        >>>
        >>>I'm not an OOD guru but maybe I sort of understand the problem. If so,
        >>>this
        >>>is not my fault, right? Since I can access ClientRectangle I don't see
        >>>why
        >>>I can't clone it. Is there anything easier/better than typing out all of
        >>>the code to make a field by field copy?
        >>>
        >>>Thanks, Bob
        >>>
        >>
        >Dim TA_rect As Rectangle = Me.ClientRectan gle
        >>
        >You get an error because Rectangle hides the MemberwiseClone method,
        >probably because it is unnecessary since Rectangle is a Value type.
        >>
        >Because Rectangle is a Value type the above statement will make a copy
        >since Value types are copied on assignment.
        >
        >Thank you VERY much Jack. I went back to take another look at the Rectangle
        >doc and it certainly makes no secret of the fact that Rectangle is a
        >Structure and not a Class. I don't know if I didn't see that or if the
        >implication just didn't register.
        >
        >BUT ... this problem caused me to do some research and thinking and I'd
        >appreciate your comments, or anyone elses, on what I think I have learned.
        >In general, in OOP, as the coder of an app, as opposed to the coder of a
        >class, this area of creating a copy of an object is, I think the technical
        >term is, mess! In general the case X=Y where Y is a Structure looks
        >straightforwar d, but if elements of Y are references then you don't really
        >end up with a complete copy. Right? The elements within Y better be value
        >types or other Structures consisting only of value types, etc.. So you
        >really have to know what your are working with when you need to make a copy
        >of it. (Of course it's always been the case in programming that you really
        >have to know what you are doing, but that is easier in some cases than in
        >others.)
        >
        >Thanks, Bob
        >
        Copy is difficult. If members of the thing being copied are
        references, then you must determine what behavior you want on copy -
        copy the references or generate new instances.

        Comment

        Working...