I want to:
- Check a variable and determine if the last 2 characters are "Id"
- If yes, remove them.
I can do it with this below, but then it will blow up if there is an "Id" substring other than the end. Is there a RemoveFromEnd() method that takes a number of characters argument?
if (column.EndsWith("Id"))
{
//remove last 2 characters
column = column.replace("Id", "");
}
I see this solution, which does this:
column = System.Text.RegularExpressions.Regex.Replace(column, "Id$", "");
but it says it's pretty slow and I am going to be running this code inside a code block that I would like to be extremely fast so I wanted to see if a faster solution is available.