I'm trying to get a new form (FormAlbum) to open when I click buttonOpenAlbum and have an item selected in the AlbumListBox.
If I just have this in buttonOpenAlbum_Click:
private void buttonOpenAlbum_Click(object sender, EventArgs e)
{
FormAlbum MusicForm = new FormAlbum(this);
MusicForm.ShowDialog();
}
The new from opens without error. However, as soon as I mention "AlbumListBox.SelectedItem" (as in the code belowin Form FormMain), I get a "StackOverflowException was unhandled" at:
public ListBox AlbumListBox
{
get
{ // <-This bracket here is where the error highlights
I don't understand why I'm getting this error, only that it must have something to do with AlbumListBox. What am I doing wrong? Any help is appreciated, thank you.
Form FormMain:
public FormMain()
{
InitializeComponent();
}
private void buttonAddAlbum_Click(object sender, EventArgs e)
{
FormAlbumAC addAlbumForm = new FormAlbumAC(this);
addAlbumForm.ShowDialog();
}
private void buttonOpenAlbum_Click(object sender, EventArgs e)
{
if (AlbumListBox.SelectedItem != null)
{
MessageBox.Show(AlbumListBox.SelectedItem.ToString());
FormAlbum MusicForm = new FormAlbum(this);
MusicForm.ShowDialog();
}
else
{
MessageBox.Show("You need to select an album from the list to open.");
}
}
public static class PublicVars
{
public static List<Album> AlbumList { get; set; }
static PublicVars()
{
AlbumList = new List<Album>(MAX_ALBUMS);
}
}
public ListBox AlbumListBox
{
get
{
return AlbumListBox;
}
}
Look at your property implementation:
public ListBox AlbumListBox
{
get
{
return AlbumListBox;
}
}
It's just calling itself, recursively. It may be easier to see that if we convert it to a method:
public ListBox GetAlbumListBox()
{
return GetAlbumListBox();
}
That's why you've got an overflow. It's not clear what you meant it to do... where did you expect the value to come from? You probably need a variable to back the property. What did you expect to set the value returned?
I'd also strongly discourage the design of the PublicVars class. Aside from the naming, you're basically using global variables - not a good idea. Work out which classes need access to the data, and how to get that data to them appropriately.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
What I want is to type in a textbox before I start my packet sniffer to only show me results that I want. This is what I have but it isn't working. I want this listview to just show port 3074 using a textbox does anyone know how to do this? This is a packet sniffer
(source: gyazo.com)
Anyone know how I can do that?
This is what I am using
namespace Network.Packet.Analyzer.App.Forms.Main
{
public partial class FrmAnalyzer : Form, IAnalyzer
{
public FormaAnalyzerPresenter _presenter;
public FrmAnalyzer()
{
InitializeComponent();
_presenter = new FormaAnalyzerPresenter(this);
}
//callled when ListView control selection being made
private void lstReceivedPackets_SelectedIndexChanged(object sender, EventArgs e)
{
_presenter.CreateDetailedTree();
}
//start button click event method
private void toolStripButton1_Click(object sender, EventArgs e)
{
_presenter.StartClicked();
}
//stop button click event method
private void tbtnStop_Click(object sender, EventArgs e)
{
_presenter.StopClicked();
}
private void Form1_Load(object sender, EventArgs e)
{
_presenter.ApplicationStarted();
}
// clear all button click event method
// clearing buffer,listvie control,and treeview
private void tbtnClearAll_Click(object sender, EventArgs e)
{
_presenter.ClearAllClicked();
}
private void closeToolStripMenuItem_Click(object sender, EventArgs e)
{
ApplicationClose();
}
private void menuAlwaysOnTop_Click(object sender, EventArgs e)
{
_presenter.TopMostClicked();
}
#region IAnalyzer Members
public ListView ListReceivedPackets
{
get { return lstReceivedPackets; }
}
public ListView ListOpenPorts
{
get
{
return lstOpenPorts;
}
}
public ProgressBar ProgressBufferusage
{
get { return progressBufferUsage; }
}
public TreeView TreePackedDetails
{
get { return treePacketDetails; }
}
public void SetTotalPacketReceivedText(string strNumber)
{
if (strNumber != null)
lblTotalPkgsReceived.Text = strNumber;
}
public void SetBufferUsage(string strNumber)
{
if (strNumber != null)
lblBufferUsage.Text = strNumber;
}
public void SetReadyText(string text)
{
if (text != null)
lblStripReady.Text = text;
}
public bool ButtonStartEnabled
{
get { return tbtnStar.Enabled; }
set { tbtnStar.Enabled = value; }
}
public bool ButtonStopEnabled
{
get { return tbtnStop.Enabled; }
set { tbtnStop.Enabled = value; }
}
public bool TopMostChecked
{
get
{
return topMostMenuItem.Checked;
}
set
{
topMostMenuItem.Checked = value;
}
}
public bool FormShowAsTopMost
{
get
{
return this.TopMost;
}
set
{
this.TopMost = value;
}
}
public void ApplicationClose()
{
this.Close();
}
public StartupInfo StartupInformation
{
get
{
return _presenter.StartupInformation;
}
set
{
_presenter.StartupInformation = value;
}
}
public void ShowErrorMessage(string message)
{
MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
public void ShowWarningMessage(string message)
{
MessageBox.Show(message, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
public void ShowDefaultErrorMessage()
{
MessageBox.Show("Unexpected error has acquired", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
public void ShowDefaultErrorMessage(Exception ex)
{
MessageBox.Show(String.Format("Unexpected error has acquired. Error message: {0}", ex.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
public void ShowErrorMessage(string message, Exception ex)
{
MessageBox.Show(String.Format("{0}. Error message: {1}", message, ex.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
public void Invoke(Action act)
{
this.Invoke(new MethodInvoker(delegate { act(); }));
}
private void button1_Click(object sender, EventArgs e)
{
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
}
#endregion
This is the other part: pastebin.com/rPWMJHCe
Okay, seeing your code from pastebin, i will keep my answer rather simple. My answer is most certainly not the best and not the most elegant, and you will certainly still hit a wall here and there, but making it better and easier to work with would most likely require abandoning ListView in favor of a more capable control (such as DataGridView, for example). Anyway...
For the example given below, i'll pick the ListView ListOpenPorts. But of course you can adapt this approach to other ListViews as well, just pay attention to keep track of where which data is stored inside the ListViewItems.
The basic idea of a filtered content display is something ListView doesn't really like. It is not so much the filtering itself, but the fact that all items must be somewhere when we change or switch off filtering. What makes ListView suck so much in this regard is that it insists to maintain the list of items internally instead of giving us the opportunity to control and swap that list easily (hence me pointing towards DataGridView earlier).
The approach involves maintaining another private list _listOpenPortItems in the class FrmAnalyzer which will keep all 'open port' ListViewItems. This is necessary so our code can access them and feed them back into the lstOpenPorts ListView whenever the filtering is switched off or changed.
private readonly List<ListViewItem> _listOpenPortItems = new List<ListViewItem>();
To always have the correct items in the _listOpenPortItems list requires to not access ListOpenPorts.Items directly. Instead, methods will be implemented in the class FrmAnalyzer which will realize equivalent functions for any function used on ListOpenPorts.Items before. Those methods manipulate the private list _listOpenPortItems and also add/remove items to/from the actual ListView control depending on the filter settings.
Also note the two properties IsPortFilterEnabled and PortToFilter, which control filtering and which i will explain a bit later.
public void AddOpenPortItem(ListViewItem openPortItem)
{
_listOpenPortItems.Add(openPortItem);
if (!IsPortFilterEnabled || PortToFilter == openPortItem.SubItems[3])
lstOpenPorts.Items.Add(openPortItem);
}
public void RemoveOpenPortItem(ListViewItem openPortItem)
{
_listOpenPortItems.Remove(openPortItem);
if (!IsPortFilterEnabled || PortToFilter == openPortItem.SubItems[3])
lstOpenPorts.Items.Remove(openPortItem);
}
//...Also implement here methods for all other functions of
//...ListOpenPorts.Items you used before (such as RemoveByKey, ContainsKey, etc...)
//...which will have to realize the equivalent function on _listOpenPortItems.
//...Any method which can potentially alter _listOpenPortItems will have to have a
//...code snippet like:
// if (!IsPortFilterEnabled || PortToFilter == openPortItem.SubItems[3])
// lstOpenPorts.Items.XXXXXX(openPortItem);
//
//...(where XXXXXX is the appropriate method of lstOpenPorts.Items)
(Note that i here assume the port number being the subitem with index 3.)
With those methods implemented, just replace all direct accesses of ListOpenPorts.Items with the respective method calls. For example:
_view.Invoke(() => _view.ListOpenPorts.Items.Remove(item));
would be replaced with:
_view.Invoke(() => _view.RemoveOpenPortItem(item));
This code change sound like difficult work, but it is actually not that hard and just a question of finding all usages of "ListOpenPorts"/"ListOpenPorts.Items" - a simple text search through your whole source code is the bigger part of the job.
To control the filter we will use the two properties i already mentioned: PortToFilter, a String property which will hold the port number to filter for; and IsPortFilterEnabled, a bool property denoting whether the filter is enabled or not.
Both properties are, like the methods above, implemented in the class FrmAnalyzer.
public bool IsPortFilterEnabled
{
get { return _isPortFilterEnabled; }
set
{
if (_isPortFilterEnabled != value)
{
_isPortFilterEnabled = value;
RefreshOpenPortListView();
}
}
}
private bool _isPortFilterEnabled = false;
public string PortToFilter
{
get { return _portToFilter ; }
set
{
//
// Note that setting PortToFilter will turn on the filter
//
if(!_isPortFilterEnabled || _portToFilter != value)
{
_portToFilter = value;
RefreshOpenPortListView();
}
}
}
private string _portToFilter = "0";
Remark: It would be better to handle port numbers as what they are - int numbers, not strings. But since you already use strings for port numbers, i chose the string data type here, too.
You might notice the calls of method RefreshOpenPortListView. This is a method which updates lstOpenPorts.Items according to the filter settings.
private void RefreshOpenPortListView()
{
//
// Note that this method does not preserve the current selection in the List View.
// If you need to preserve it, save the current selection here and restore it
// at the end of this method again.
//
IEnumerable<ListViewItem> itemsForListView =
(_isPortFilterEnabled) ?
_listOpenPortItems.Where(item => PortToFilter == item.SubItems[3])
: _listOpenPortItems;
lstOpenPorts.BeginUpdate();
_lstOpenPorts.Itmes.Clear();
foreach(ListViewItem item in _itemsForListView)
_lstOpenPorts.Add(openPortItem);
_lstOpenPorts.EndUpdate();
}
(Note that i here assume the port number being the subitem with index 3.)
Finally, how do you set IsPortFilterEnabled and PortToFilter? Here one idea briefly outlined, but there a numerous different ways of how to do that:
Let a checkbox toggle the value of IsPortFilterEnabled. This checkbox basically enables/disables the filtered view.
Let a (numerical) textbox dump its content into PortToFilter. This textbox contains the port number to filter for. Note that (according to my suggested implementation) whenever the textbox transfers its content to PortToFilter, the filtered view is enabled and updated.
You want to sort or filter?, your title says sort, but your description says "to just show those results"
If your Listview is bound to a DataTable, then you can filter or sort using the DefaultView property.
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (comboBox1.SelectedIndex == 0)
dtItems.DefaultView.Sort = "ID";
else
dtItems.DefaultView.Sort = "Name";
MyBindMethod(dtItems);
}
Or if you want to filter by ID
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
dtItems.DefaultView.RowFilter = "ID = '" + comboBox1.SelectedValue + "'";
MyBindMethod(dtItems);
}
This question already has answers here:
What is a NullReferenceException, and how do I fix it?
(27 answers)
Closed 7 years ago.
I cannot figure out why I am getting this error. I am setting an instance to the object I am trying to create. Any help would be really appreciated. I will post my form code and then the class code below that. The application runs fine, it just gives me that null reference error when I click on btnAdd.
public partial class frmProperties : Form
{
Agent curAgent;
PropertyCollection pc;
int currRecord;
public frmProperties()
{
InitializeComponent();
}
public frmProperties(Agent ac, PropertyCollection pcPassed)
{
InitializeComponent();
curAgent = ac;
pc = pcPassed;
}
//check if there is a property in the list
private void frmProperties_Load(object sender, EventArgs e)
{
if (curAgent.AgentPropertyList.Count > 0)
ShowAll();
}
private void btnNext_Click(object sender, EventArgs e)
{
if (currRecord < curAgent.AgentPropertyList.Count - 1)
{
currRecord++;
ShowAll();
}
else MessageBox.Show("No more properties to view");
}
void ShowAll()
{
txtId.Text = curAgent.AgentPropertyList[currRecord].ToString();
Property p = pc.FindProperty(curAgent.AgentPropertyList[currRecord]);
}
private void btnShowPrev_Click(object sender, EventArgs e)
{
if (currRecord > 0)
{
currRecord--;
ShowAll();
}
else MessageBox.Show("No more properties to view");
}
private void btnAdd_Click(object sender, EventArgs e)
{
pc.AddProperty(Convert.ToInt32(txtId.Text), txtAddress.Text, Convert.ToInt32(txtBedrooms.Text), txtType.Text, Convert.ToInt32(txtSqFt.Text), Convert.ToDouble(txtPrice.Text), txtAgent.Text);
}
private void btnExit_Click(object sender, EventArgs e)
{
this.Close();
}
}
Here is the code to the class that the add function was created in:
public class PropertyCollection
{
// list of properties
List<Property> propertyList = new List<Property>();
public List<Property> PropertyList
{
get { return propertyList; }
set { propertyList = value; }
}
public void AddProperty(int id, string address, int bedrooms, string type, int sqft, double price,string agent)
{
Property p = new Property(id,address,bedrooms,type,sqft,price,agent);
propertyList.Add(p);
}
public void RemoveProperty(int id)
{
Property rem = new Property(id);
propertyList.Remove(rem);
}
//loop through and find equivalent
public Property FindProperty(int id)
{
Property find = new Property(id);
for (int i = 0; i < propertyList.Count; i++)
if (propertyList[i].Equals(find))
return propertyList[i];
return null;
}
//Count property and INDEXER
public int Count
{
get { return propertyList.Count; }
}
public Property this[int i]
{
get { return propertyList[i]; }
set { propertyList[i] = value; }
}
}
Your default constructor isn't initialising pc; You could change it to the following:
public frmProperties()
{
InitializeComponent();
pc = new PropertyCollection(/* any params here */);
}
I am posting this as I am more or less peaved at the 5 upticks to check the breakpoint as it showed the commentor did not read the question.
Posted stated receiving System.NullReferenceException {“Object reference not set to an instance of an object.”} when clicking on the btnAdd_Click method
So we look at this method and it shows we are only accessing 1 variable named pc. The error tells us we have an object that has not been initialized. So we look to see if the variable is define, sure is. now we look to see whereit is initialized so lets look at the constructors.
//this constructor does not initialize any variables, just the form
public frmProperties()
{
InitializeComponent();
}
//this constructor initializes the variables but does not check for null
public frmProperties(Agent ac, PropertyCollection pcPassed)
{
InitializeComponent();
curAgent = ac;
pc = pcPassed;
}
so we have two issues that could result in the proceeding exception.
1) the default constructor is being called therefor pc is never initialized
2) the second constructor is being called and pcPassed has a value of null.
so to fix this we could remove the first constructor requiring that the arguments be passed in in order to start the form then we just need to check for null on the variables. Or leave the default constructor and call the correct one passing in default values or nulls, I suggest nulls that way all processing is done in the constructor with args. So the fix would be
//default constructor calling the correct constructor with params.
public frmProperties() :this(null,null) { }
public frmProperties(Agent ac, PropertyCollection pcPassed)
{
InitializeComponent();
if(ac != null) //check for null values
curAgent = ac;
else
curAgent = new Agent();
if(pcPassed != null)//check for null values
pc= pcPassed;
else
pc = new PropertyCollection();
}
so in short you dont need the breakpoint as you already know that the object was not initialized as that is what the exception was telling you.
I am creating a Custom control in where I am creating a property of the type "List"
Sections is a public class which has 4 properties.
The code in the control looks as follows:
public partial class genericGauge : Control
{
public genericGauge()
{
InitializeComponent();
}
// Stripped out code not needed for this issue question.
private List<Sections> indicators = new List<Sections>();
public List<Sections> Indicators
{
get
{
return indicators;
}
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
// Stripped out code not needed for this issue question.
}
}
The Sections Class is as follows:
public class Sections
{
private string header = "Section1";
public string Header
{
get {return header;}
set
{
header = value;
}
}
private float startvalue = 0.0f;
public float StartValue
{
get { return startvalue; }
set
{
startvalue = value;
}
}
private float sweepvalue = 0.0f;
public float SweepValue
{
get { return sweepvalue; }
set
{
sweepvalue = value;
}
}
private Color sectioncolor = new Color();
public Color SectionColor
{
get {return sectioncolor;}
set
{
sectioncolor = value;
}
}
}
Everything seems to work fine except that when I add items to the collection at designtime using the property browsers typeeditor the control is not repainted to reflect what is added to the collection.
When I click outside the control on my testform it is repainted.
Usually with simple properties I would use Invalidate, but this seems not to be possible here.
I also tried with other collection types than List<> where it is allowed to have a set accessor, but Invalidate still wont be called. I assume that it means that the SET is never called.
I know how to get this to work with expandable properties but I have no luck finding how to make this update with collections.
I hope someoone can help me out.
thanks in advance.
Instead of using the class List, use the class ObservableCollection, and use that to get notified when a new section is added or removed from the list.
private ObservableCollection<Sections> indicators = new ObservableCollection<Sections>();
public IList<Sections> Indicators
{
get
{
return indicators;
}
}
public genericGauge()
{
InitializeComponent();
this.indicators.CollectionChanged += this.IndicatorsCollectionChanged;
}
private void IndicatorsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
// possibly inspect the NotifyCollectionChangedEventArgs to see if it's a change that should cause a redraw.
// or not.
this.Invalidate();
}
When using your example exactly as it was the Indicators property was not available for editing in the property window. So I made a few changes to it.
I added a new class:
// Added this class to deal with the Sections class
public class SectionObservable : ObservableCollection<Sections>
{
// Added a few methods here for creating a designtime collection if I need to.
}
Then I made the change as you suggested
public genericGauge()
{
InitializeComponent();
this.indicators.CollectionChanged += this.IndicatorsCollectionChanged; // your suggestion
}
And made the property like this instead:
private SectionObservable indicators = new SectionObservable(); // using the SectionObservable class instead
public SectionObservable Indicators // using the SectionObservable class instead
{
get
{
return indicators;
}
}
private void IndicatorsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) // your suggestion
{
this.Invalidate();
}
And now works as a charm.
Thank you very much. I appreciate to see that it IS possible to get help this fast. I like this forum alot.
Ok so I am trying to pass a boolean from my Login form to my Home form, normally this would be fine for me and I would just use a property. However I thought I could use a similar method this time but I am implementing the singleton factory on the forms.
Here is the Login code relevant to this:
The AdminAccess property gets set fine and I have checked the value is correct.
private bool adminAccess;
public bool AdminAccess
{
get { return adminAccess; }
private set { adminAccess = value; }
}
private void btnLogin_Click(object sender, EventArgs e)
{
//Some Code Does Stuff
OpenHome();
}
private void OpenHome()
{
HomeForm CreateHomeForm = HomeForm.HomeUI;
CreateHomeForm.StartupHome = this;
//Trying to set the property.
CreateHomeForm.AdminPermissions= this.AdminAccess;
CreateHomeForm.Show();
this.Hide();
}
Here is the relevant code from the Home form:
public HomeForm()
{
InitializeComponent();
//just to check what is in the property quickly
textBox1.Text = AdminPermissions.ToString();
}
private bool adminPermissions;
public bool AdminPermissions
{
private get { return adminPermissions; }
set { adminPermissions = value; }
}
public Form StartupHome
{
set;
get;
}
private static HomeForm homeUI;
public static HomeForm HomeUI
{
get
{
if (homeUI == null || homeUI.IsDisposed)
{
homeUI = new HomeForm();
}
return homeUI;
}
}
The value gets reset when the HomeUI if loop runs as a new instance of the form is created. I can't seem to think how to modify this to get a working solution. As you can tell I am fairly amateur so I'm just looking for a quick and clean solution to this :)
Thank you very much for your time in advance!
You assign the value in the constructor, BEFORE the AdminPermissions property is actually set. Change your code like this
public class HomeForm
{
public HomeForm()
{
InitializeComponent();
}
private bool adminPermissions;
public bool AdminPermissions
{
get { return adminPermissions; }
set {
adminPermissions = value;
textBox1.Text = value.ToString();
}
}
...
}
Try setting the textBox1.Text value in one of the Form events. Try Loaded first, then Activated. You're resetting it to false every time in your constructor!
I have a second window which opens when a certain staffname is searched for, this window prompts you to choose between the 2 staff members with the same name. The window then needs to return a value to the parent window to populate a datatemplate with relating data from the xml file.
I've tried to create a string which will be updated with a value depending on which button is clicked, this string can then be returned to the calling method on the first window and populate binding data in the Linq to Xml query.
But when it runs it causes a stackoverflow exception and that it could be an infinite loop. I'm not sure enough about c# to know what to change.
public partial class Choice : Window
{
private string StaffChoice;
public Choice()
{
InitializeComponent();
}
public string staffChoice
{
get { return this.StaffChoice; }
set { staffChoice = StaffChoice; }
}
private void btnMRG_Click(object sender, RoutedEventArgs e)
{
StaffChoice = "MRG";
this.Close();
}
private void btnRPG_Click(object sender, RoutedEventArgs e)
{
StaffChoice = "RPG";
this.Close();
}
}
Any help or suggestions would be great!
Thanks in advance!
Firstly, your naming conventions are wrong - the field should be called staffChoice and the property should be called StaffChoice. Please read the .NET naming conventions for more information. However, now look at your property closely:
public string staffChoice
{
get { return this.StaffChoice; }
set { staffChoice = StaffChoice; }
}
What do you think the setter does? There are two problems with it:
It ignores the value that you're trying to set it to.
It calls itself recursively.
You could fix this by keeping the manually-declared field, fixing the naming conventions, and changing the property to set the variable to value like this:
private string staffChoice;
public string StaffChoice
{
get { return staffChoice; }
set { staffChoice = value; }
}
However, it would be simpler to use an automatically implemented property:
public string StaffChoice { get; set; }
This will create the backing field and the getter/setter for you automatically.
The simplest way is to declare a property like this...
public string StaffChoice { get; set; }
your problem is you are basically calling the property setter from within the same setter - thus you have a recursive loop. You could change your code like this to make it work...
private string StaffChoice;
public string staffChoice
{
get { return this.StaffChoice; }
set { StaffChoice = value; }
}
Your setter isn't right, you are assigning a value to itself (causing the infinite loop) and not using value.
You should change your code to this, your naming convention looked backwards so I corrected it, hope you don't mind:
private string staffChoice;
public Choice()
{
InitializeComponent();
}
public string StaffChoice
{
get { return staffChoice; }
set { staffChoice = value; }
}
private void btnMRG_Click(object sender, RoutedEventArgs e)
{
staffChoice = "MRG";
this.Close();
}
private void btnRPG_Click(object sender, RoutedEventArgs e)
{
staffChoice = "RPG";
this.Close();
}
Your property should be:
public string staffChoice
{
get { return this.StaffChoice; }
set { this.StaffChoice = value; }
}
In your code you are calling the setter again in the setter - hence the infinite recursion.
However, as you are not doing anything special in the setter (like notifying the UI that the property has changed you could simply have:
public string staffChoice { get; set; }
This "auto property" is a little cleaner.
(BTW: the normal practice is to have the back variable starting with a lower case letter and the public property starting with an upper case one. However, if you are consistent in your application it doesn't really matter.)