c# remove last character from string code example
Example 1: c# remove last character from string
string Name = "Teste,"
string ReturnName = "";
ReturnName = Name.Remove(Name.Length - 1);
Example 2: remove last character from string c#
myString = myString.Substring(0, myString.Length-1);
Example 3: how to remove last 3 characters from string in c#
myString = myString.Substring(0, myString.Length-3);
Example 4: remove last instance of string c#
public static string ReplaceLastOccurrence(string Source, string Find, string Replace)
{
int place = Source.LastIndexOf(Find);
if(place == -1)
return Source;
string result = Source.Remove(place, Find.Length).Insert(place, Replace);
return result;
}
Example 5: vb.net remove last char from string
temp = temp.Trim().Remove(temp.Length - 1)
Example 6: c# remove last character from string
string Name = "Teste,"
string ReturnName = "";
ReturnName = Name.Remove(Name.Length - 1);
myString = myString.Substring(0, myString.Length-3);