473,587 Members | 2,267 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"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
Sep 28 '08 #1
3 4284
On Sun, 28 Sep 2008 17:16:25 -0400, "eBob.com"
<eB******@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.
Sep 29 '08 #2

"Jack Jackson" <jj******@cinno vations.netwrot e in message
news:a6******** *************** *********@4ax.c om...
On Sun, 28 Sep 2008 17:16:25 -0400, "eBob.com"
<eB******@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
Sep 29 '08 #3
On Mon, 29 Sep 2008 11:51:06 -0400, "eBob.com"
<eB******@total lybogus.comwrot e:
>
"Jack Jackson" <jj******@cinno vations.netwrot e in message
news:a6******* *************** **********@4ax. com...
>On Sun, 28 Sep 2008 17:16:25 -0400, "eBob.com"
<eB******@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.

Sep 29 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
19186
by: H. S. | last post by:
I am getting this error if I try to compile the file demarcated below. What I am missing here? I am using g++ (GCC) 3.3.5 (Debian 1:3.3.5-8). {tp2}> g++ -ansi -g -Wall tp2.cc -o tp2 tp2.cc: In member function `void Other::DoSomething()': tp2.cc:11: error: `int Base::iX' is protected tp2.cc:29: error: within this context // %< %< ...
72
4168
by: Paminu | last post by:
In math this expression: (a < b) && (b < c) would be described as: a < b < c But why is it that in C these two expressions evaluate to something different for the same values of a, b and c?
2
5061
by: Andreas Klemt | last post by:
Hello, what is the difference between a) Protected WithEvents myClassName b) Protected myClassName Thanks, Andreas
0
1351
by: hansiman | last post by:
I sometimes see references to controls that has been removed from the aspx page in the code behind. The references linger in the region "Web Form Designer Generated Code" and look like Protected WithEvents lblLabel1 As System.Web.UI.WebControls.Label Why do they persist and is there a was to remove them easily? /M
10
1629
by: Eric G. Harrison | last post by:
We have a project with many other projects referenced (all of which are referenced at the project level and are included in the solution). Frequenly, if we make a change in project A (such as adding a property, or even simply changing a line of code), a form in project B will then show 10 or more "object such-and-such is not defined". To fix...
3
6700
by: Jordan Taylor | last post by:
I am confused about protected member functions and objects. Is there any particular advantage of declaring members protected?
2
9908
by: Jeff | last post by:
hey asp.net 2.0 (C'#) In the code behind file I have this method: public String AddBR(Object param) { String text = (String) param; return text; }
3
11615
by: Michael | last post by:
Hi, I am getting a strange error. Last night when I left work this was working perfectly. This morning when I try to run this code in VS2005, it comes up with an error saying "The name 'UserName' does not exist in the current context". I don't know what to do about it. The field is there. It worked yesterday. Any ideas? HTML CODE:...
4
2094
by: R.A.M. | last post by:
Hello, I am writing ASP.NET application in which I need to use User Profiles and Session mechanisms. Here I include part of my source code (Admin.cs): using System; using System.Data; using System.Data.Sql; using System.Data.SqlClient; using System.Data.SqlTypes;
0
8339
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7967
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8220
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6619
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5712
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5392
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3840
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2347
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1452
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.