trim string at the end of the string

前端 未结 6 817
时光说笑
时光说笑 2021-01-16 07:01

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\"
         


        
6条回答
  •  死守一世寂寞
    2021-01-16 07:18

    also, can be done via

    //............
    string query = SELECT * FROM People WHERE City = @City AND County = @County AND";
    char[] charsAND = { 'A', 'N', 'D'};
    char[] charsOR = { 'O', 'R'};
    query = query.Trim().TrimEnd(charsAND).TrimEnd(charsOR);
    //
    

提交回复
热议问题