For a property of type string, I use the following condition in an if statement....
value.Length > maxLength
When I go to run the program in visual studios 2008 express debugger, I receive the following error message "Object reference not set to an instance of an object". Why am I getting that error message? The property is of type string and the value keyword should reference the instance of that string, right? I tried also using the field corresponding to the property instead of value.Length, but that didn't work either. It just popped up with the same warning. How do I go about fixing this?
I've attached the relevant code below.
public string CakeWriting
if (CakeSize == 8)
maxLength = 16;
maxLength = 40;
if (value.Length > maxLength)
MessageBox.Show("Too many letters for a " + CakeSize + " inch cake");
if (maxLength > this.cakeWriting.Length)
maxLength = this.cakeWriting.Length;
this.cakeWriting = cakeWriting.Substring(0, maxLength);
this.cakeWriting = value;