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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

string.Substring DOES NOT EXIST

Status
Not open for further replies.

CodingIsFun

Programmer
Apr 9, 2004
134
US
Anyone come across this.

here is my code:

using System;
using System.Net;
using System.Xml;
using System.Collections;

namespace test
{

public class string_test
{
public string string_test(string t)
{
return t.Substring(1,1);
}
}
}

I get the error t.Substring does not exists
In the command window if I type ? t it returns the string content. If I do the same in the command window t.Substring(1,1) I get the same error.

Am I missing a reference to the string functions.

thanks in advance..
 
You could change your string to a character array, and then take chunks of that and turn it into a new string.
 
string to a character array
Only works for western scripts. There are some unicode scripts that make heavy use of surrogates that will cause this to fail. If that's not a problem, then it's a valid approach.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Hey Chip,

Are you writing apps in Chinese again? :)

You are absolutely correct. But if something as silly as Substring is not working, it may be a valid choice.
 
Hey, China is a huge market!
:)

I think something more fundamental is wrong with the OP's system, which is why I suggested a reinstall.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top