Last Char or Endswith problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • BarryM
    New Member
    • Mar 2008
    • 32

    Last Char or Endswith problem

    Hi im new to c# that just changed from vb 2005 and my question is how to check if the last char is the letter "a" or not"

    i had tries this but came up with a error
    Code:
       if (txttext.Text.EndsWith == "a") 
                {
                }
    or is there way to check the last char
    note this is in vb 2005
    Code:
    if txttex.text.chars(txttext.lenght -1 ) = "a" then
    end if
    im using the c# 2005 express edition
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    You were on the right track, except that EndsWith is a method not a property. So you needed to use it like this
    Code:
    if(text.EndsWith("a")) { //with the brackets
    //do stuff
    }
    P.S You posted this in the C++ forum instead of the .NET forum where it belongs. I will now move it there for you.

    Comment

    • BarryM
      New Member
      • Mar 2008
      • 32

      #3
      thanks for your help :}

      Comment

      Working...