Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

String Functions "Does Not Exist"

Status
Not open for further replies.

neilkonitzer

Programmer
Jun 27, 2001
168
US
I know that my problem has got to be something really stupid...

For some reason, all my string methods do not work, even though intellisense picks them up as valid.

For example:
string Test1 = "Test";
string Test2 = Test1.Substring(0,2);

The second line returns an error stating "error: "Test1.SubString' does not exist.

Has anyone encountered this before? This applies to all the standard string methods.

Neil Konitzer
Freisoft
 
The following code will work:
using System;
namespace XXX
{
/// <summary>
/// Summary description for Class1.
/// </summary>
public class Class1
{
public Class1()
{
//
// TODO: Add constructor logic here
//
}
void private Foo()
{
string Test1 = &quot;Test&quot;;
string Test2 = Test1.Substring(0,2);
//....
}

}
}

but I think you put the two statements ouside of any function, and you cannot do that.
-obislavu-



 
Are you using the StringBuilder class?
You'll need the &quot;System.Text&quot; namespace for that.

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
> The second line returns an error
> stating &quot;error: &quot;Test1.SubString'
> does not exist.

If that is the exact error message, then the problem is that you got the case wrong (because C# is case sensitive). In your sample code you wrote it correctly though (&quot;Substring&quot;), so either your sample code isn't as you have it on your computer, or the error message has a typo.

Something to check anyway.
 
Hi,
Can you build a small application without using System.String ?
If yes then please add only one statement like string Test1=&quot;&quot;; somewhere and post the code if it doesn't work.
-obislavu-
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top