Remove last special character if last character is question mark. First we have to check the last character in given string is question mark or not. If last character is question mark then we remove the last character.
You can remove any last specific character if it exists at last position with the help of given example using c#. This function will retrurn text without special charcter ?.
public static string RemoveLastSpecialCharcter(string text)
{
var last_character = text[text.Length - 1];
if (last_character == '?')
{
text = text.Remove(text.Length - 1);
}
return text;
}
Post your comments / questions
Recent Article
- How to use if else statement in c++?
- How to use godaddy domain name with another godaddy hosting account?
- Restore of database 'DATABASE' failed. (Microsoft.SqlServer.Management.RelationalEngineTasks)
- How to programmatically modifying the AppSetting value in web.config using c#?
- TypeError [ERR_INVALID_CALLBACK]: Callback must be a function. Received undefined
- How to calculate the age from jQuery ui datepicker using c#?
- How to calculate days difference between two dates in c#?
- Changing date format in jQuery ui datepicker
Related Article