473,385 Members | 1,806 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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()
{
InitializeComponent();
//tp_ is ok here
}
private void OKButton_Click(object sender, EventArgs e)
{
// tp_ is null if declared with private
tp_.Name = TiepointName_Text.Text;

DialogResult = DialogResult.OK;
}
}

Thanks for any answers
Frank
Apr 21 '06 #1
1 1199
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
by: kchalla | last post by:
Can anybody let me know the difference between public and private class access modifiers? Thanks in advance
2
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...
3
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 ...
4
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...
1
by: Ashkan Daie | last post by:
Hi All, Is there an internal access modifier in managed vc++ like vc#? Thanks, Ashkan
6
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...
4
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...
5
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...
3
by: RitualDave | last post by:
This compiles and runs successfully in VS2005: ref class A { private: ~A() { this->!A(); } // private! !A() { } // private! }; ....
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.