Input : str = "AML,Bladder Cancer,";
public static string RemoveLastCharacter(string str) //str = "AML,Bladder Cancer,"
{
if (string.IsNullOrEmpty(str)) return "";
if (str.EndsWith(","))
{
str = str.Substring(0, str.Length - 1);
}
else if (str.EndsWith(";"))
{
str = str.Substring(0, str.Length - 1);
}
return str; // "AML,Bladder Cancer"
}
Result : "AML,Bladder Cancer"