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

Identifier expected when using String.char

Status
Not open for further replies.

TheDust

Programmer
Aug 12, 2002
217
US
I am getting the following error:
CS1041: Identifier expected, 'char' is a keyword

Below is a simplified version of what I'm doing. (C#)

Code:
using System;

public class classAddProject : System.Web.UI.Page {
  protected void Submit_Click(Object Src, EventArgs E) {
    string date = "something";
    if (date.char[x - 1] == "/") {
      // stuff happens
    }
  }
}

Does "char" have its own separate namespace that needs declaring, and if so, how? Any help is appreciated...

Dust
 
No, that comes up with:

'string' does not contain a definition for 'chars'

Any other ideas?
 
Capitalizing 'chars' to 'Chars' does nothing. ASP.NET is still telling me that 'string' does not contain a definition for 'Chars'...
 
the string class has an indexer on it.

So:

date[x - 1]

should work (Although the docs do show a .Chars property, which should do the same thing).

[poke]

penny.gif
penny.gif

The answer to getting answered -- faq855-2992
 
Cool... that did it, thanks!

I wonder why I could not find any examples of this anywhere... oh well. Again, thanks a lot!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top