Method calls don't exist?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Driving me nuts.

Web page calls a function in a different class library that is to return a
string.

Inside this function, I create a string, give it a value, then try to do a
string.replace.

Fails. Though I can do stringname.length and get the property, if I try any
of the methods (Replace, Remove, ToUpper, ToLower, etc.), it tells me:

stringname.Replace does not exist.

Yet while debugging, I get autocomplete when I type stringname. but still,
no methods 'exist.'

Any ideas?

TIA

jdn
(e-mail address removed)
 
jdn said:
Web page calls a function in a different class library that is to return a
string.

Inside this function, I create a string, give it a value, then try to do a
string.replace.

Fails. Though I can do stringname.length and get the property, if I try any
of the methods (Replace, Remove, ToUpper, ToLower, etc.), it tells me:

stringname.Replace does not exist.

Yet while debugging, I get autocomplete when I type stringname. but still,
no methods 'exist.'

Any ideas?

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.
 
I don't have the exact code with me, but here's a reproduction:

public string CleanString(BusinessObject oBusinessObject)
{
string m_TempString = "";
string OldValue = "";
OldValue = oBusinessObject.FunctionToGetOldValue;
m_TempString = oBusinessObject.StringToClean.Replace(OldValue, "");
return m_TempString;
}

Where FunctionToGetOldValue does database stuff, and StringToClean is a
property of the business object.

The .Replace call fails. If I type in ?OldValue in the command window while
debugging, I get the value (which is wrong in itself I think), and I can do
?OldValue.Length fine, but again, if I type in ?OldValue.Replace("blahblah",
""), I get the error:

"OldValue.Replace" does not exist.

jdn
 
Back
Top