473,770 Members | 5,426 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Beginner question on access modifiers

I have a form implemented as shown below. If I define the tp_
data member as private it is always null in the Click event
handler. When I remove private and let it use the default
access ( which I think is private ) then it is ok ( non null ) in the
Click handler. I don't understand why?

public partial class Properties_Form _TiePoint : Form
{
// this declaration works ok
Tiepoint tp_ = new Tiepoint();

// this one doesn't
// private Tiepoint tp_ = new Tiepoint();

public Tiepoint ImageTiePoint
{
get { return tp_; }
set { tp_ = value; }
}

public Properties_Form _TiePoint()
{
InitializeCompo nent();
//tp_ is ok here
}
private void OKButton_Click( object sender, EventArgs e)
{
// tp_ is null if declared with private
tp_.Name = TiepointName_Te xt.Text;

DialogResult = DialogResult.OK ;
}
}

Thanks for any answers
Frank
Apr 21 '06 #1
1 1220
I have a form implemented as shown below. If I define the tp_
data member as private it is always null in the Click event
handler. When I remove private and let it use the default
access ( which I think is private ) then it is ok ( non null ) in the
Click handler. I don't understand why?


No, it doesn't make sense. As you said yourself, private is the
default so the result should be the same. I think there's something
else in your code that's causing it. Can you simplify your code to a
small complete program that reproduces the problem?
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Apr 21 '06 #2

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

Similar topics

3
1750
by: kchalla | last post by:
Can anybody let me know the difference between public and private class access modifiers? Thanks in advance
2
2745
by: Bob Weiner | last post by:
Is it possible to create a property and specify different access modifiers for the get and set methods? From the property definition it appears that you can define attributes but not access modifiers. I have never used attributes so I don't know if they are useful for this purpose. What I want to do is to create an 'Entry' class that will be used by two other classes. One class will create the 'Entry', assign limits, a default value...
3
3084
by: Pete | last post by:
Hello Can anyone provide advice/links on somewhere to get a definitive explanation with Examples of how "protected internal" differs from "protected", "internal" and the other access modifiers For "protected internal" some places appear to say it means a union of protected AND internal, other places say it's protected OR internal Thanks Pet
4
3215
by: Picho | last post by:
Hi all, Using reflection, I can invoke/call private methods of an object. is this intended? if yes, why? in what scenario (example would be good) should I be givven the option to use something that was declared private (not public) and not mine to use? seems to me this is somewhat malicious... if not.... well....
1
1864
by: Ashkan Daie | last post by:
Hi All, Is there an internal access modifier in managed vc++ like vc#? Thanks, Ashkan
6
4927
by: androoo | last post by:
I have a source database which stores the main image. I read the image out as this : Dim strSQL As String Dim objData As clsDatabase Dim dr As OleDb.OleDbDataReader strSQL += "select * from picstable" ' this is a foxpro database 'open object for database work objData = objData.GetInstance
4
1670
by: Yoram Biberman | last post by:
I have a few questions concerning concurrency control. I shall thank whoever can help me. Question #1 ========= Assume the following (concurrent) schedule, in which both transactions run in a serializable isolation level: T1 begin T2 begin T1 modifies an item A
5
9181
by: dost | last post by:
can u tell me the diffrence between...... private public and protected .........in........these.......which one...is access modifier....and which one..is specifier....... and....the diffrence between...modifier and specifier in c++ thanks
3
2468
by: RitualDave | last post by:
This compiles and runs successfully in VS2005: ref class A { private: ~A() { this->!A(); } // private! !A() { } // private! }; ....
0
9595
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10232
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10059
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9873
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6682
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5313
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5454
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3578
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2822
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.