S
Shane.H.1
Hi
Im learning C sharp, and I am trying to grok exceptions
Using the following code name is returning "N/A" where I want it to
return the string held by tempHold
What am I doing wrong?
public string Name
{
get{
return name;
}
set{
string tempHold = value;
if(value.Length >14){
//value.Length = -0;
string tempStr = value;
tempHold = "";
for (int i = 0; i <=14;i++){
tempHold += tempStr;
}
value = tempHold;
Exception e = new Exception("Error the name must be less than 14
characters long: name now equals" + tempHold);
throw e;
}
name = value;
}
}
Im learning C sharp, and I am trying to grok exceptions
Using the following code name is returning "N/A" where I want it to
return the string held by tempHold
What am I doing wrong?
public string Name
{
get{
return name;
}
set{
string tempHold = value;
if(value.Length >14){
//value.Length = -0;
string tempStr = value;
tempHold = "";
for (int i = 0; i <=14;i++){
tempHold += tempStr;
}
value = tempHold;
Exception e = new Exception("Error the name must be less than 14
characters long: name now equals" + tempHold);
throw e;
}
name = value;
}
}