Click here to Skip to main content
15,885,780 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
hello,


my question is that how to find last character of a word Example_10 or any word...
Posted
Updated 22-Nov-19 3:54am

Try this:-

C#
char c = youText.Last();
 
Share this answer
 
Comments
shwiuwew 17-Nov-11 6:25am    
Thanks a lot
Wayne Gaylard 17-Nov-11 6:35am    
No problem.
Simple way

str = str.Substring(str.Length - 1);
 
Share this answer
 
Use the following codes:
C#
string sAllCharacter="abcdef....yz";
char cLastCharacter=sAllCharacter[sAllCharacter.Lenght-1];

output=z;
 
Share this answer
 
v2
Comments
André Kraak 17-Nov-11 6:13am    
Edited answer:
Added pre tags
shwiuwew 17-Nov-11 6:24am    
Thanks a lot
 
Share this answer
 
v2
Comments
shwiuwew 17-Nov-11 6:25am    
Thanks a lot
Hi,
C#
string inputString = "CodeProject";
string lastCharacter = inputString.Substring(inputString.Length - 1);
 
Share this answer
 
v2
Comments
André Kraak 17-Nov-11 6:12am    
Edited answer:
Added pre tags
shwiuwew 17-Nov-11 6:25am    
Thanks a lot
C#
string inputText = "Example_10";
textBox1.Text = inputText.Remove(0,inputText.Length-1);
 
Share this answer
 
v2
Comments
shwiuwew 17-Nov-11 6:25am    
Thanks a lot
C#
/**
* 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;

    }
}
 
Share this answer
 
try this one

C#
String s="Some text";
string last = s.Substring(s.Length - 2, 1);
 
Share this answer
 
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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900