Click here to Skip to main content
13,556,624 members
Rate this:
 
Please Sign up or sign in to vote.
See more:
hello,


my question is that how to find last character of a word Example_10 or any word...
Posted 17-Nov-11 0:02am
Updated 5-Feb-18 5:10am
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 5

Use the following codes:
string sAllCharacter="abcdef....yz";
char cLastCharacter=sAllCharacter[sAllCharacter.Lenght-1];

output=z;
  Permalink  
v2
Comments
Andre-Kraak 17-Nov-11 6:13am
   
Edited answer:
Added pre tags
shwiuwew 17-Nov-11 6:24am
   
Thanks a lot
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 6

Simple way

str = str.Substring(str.Length - 1);
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
v2
Comments
shwiuwew 17-Nov-11 6:25am
   
Thanks a lot
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

Hi,
string inputString = "CodeProject";
string lastCharacter = inputString.Substring(inputString.Length - 1);
  Permalink  
v2
Comments
Andre-Kraak 17-Nov-11 6:12am
   
Edited answer:
Added pre tags
shwiuwew 17-Nov-11 6:25am
   
Thanks a lot
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 4

Try this:-

char c = youText.Last();
  Permalink  
Comments
shwiuwew 17-Nov-11 6:25am
   
Thanks a lot
WayneGaylard 17-Nov-11 6:35am
   
No problem.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 7

string inputText = "Example_10";
textBox1.Text = inputText.Remove(0,inputText.Length-1);
  Permalink  
v2
Comments
shwiuwew 17-Nov-11 6:25am
   
Thanks a lot
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 8

/**
* Note that Java console applications need to be run through the java runtime
* by running "java -jar JarFile.jar" in the command line.
* Java console applications can not be previewed in the Compilr IDE, only applets can.
*/
public class isPalindrome
{

    public static boolean status = true;

    static String word;
    static int strLength = word.length();

    public void setword(String word)
    {

        isPalindrome.word = word;

    }
    public String[] getWord()
    {
        String[] word = new String[] {"Nothign", "super"};
        return word;
    }

    /**
    * This is the main entry point for the application
    * @return
    */
    public static void main(String[] args)
    {
        if (status == false )
        {
            System.out.println("You didn't entered a Palindrome");
        }
        else
        {
            System.out.println("You entered a Palindrome" + get.word);
        }

    }

    public static void isValidEmpNum(String[] array, String s)
    {

        if(s.charAt(0) == s.charAt(strLength - 1))
            status = true;
        else
            status = false;

        return;

    }
}
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

try this one

String s="Some text";
string last = s.Substring(s.Length - 2, 1);
  Permalink  
v2
Comments
shwiuwew 17-Nov-11 6:25am
   
Thanks a lot

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web03 | 2.8.180515.1 | Last Updated 5 Feb 2018
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100