Hello I want to remove the last word from my sentence in C#. Here is my query:
\"SELECT * FROM People WHERE City = @City AND County = @County AND\"
>
string myString = "SELECT * FROM People WHERE City = @City AND County = @County AND";
Console.WriteLine(myString.Substring(0, myString.LastIndexOf(' ')));
But you may also consider building your AND-clause without the last AND from the beginning.
List andConditions = new List();
andConditions.Add("City = @City");
andConditions.Add("County = @County");
string myString = "SELECT * FROM People WHERE " + string.Join(" AND ", andConditions);