本文介绍了如何扭转字的顺序查询或c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经存储在数据库中作为

i have stored in the database as

位置

印度泰米尔纳德邦,钦奈,Annanagar

India,Tamilnadu,Chennai,Annanagar

而我在网格绑定查看它会被作为显示
印度泰米尔纳德邦,钦奈,Annanagar'这种格式。

while i bind in the grid view it ll be displaying as 'India,Tamilnadu,Chennai,Annanagar' this format.

但我需要这种格式显示为Annanagar,晨奈,泰米尔纳德邦,印度。如何查询或在C#中执行此相反的顺序

but i need to be displayed as 'Annanagar,Chennai,Tamilnadu,India' in this format. how to perform this reverse order in query or in c#

请注意:这是存储在一个列作为印度的泰米尔纳德邦,钦奈,Annanagar用逗号分隔

note: this is stored under one column as 'India,Tamilnadu,Chennai,Annanagar' with comma separated.

推荐答案

我相信OP提供的位置的例子就是从DB只是一个结果,他正在寻找的东西是这样的:

I believe location example provided by OP is just one result from DB and he is looking for something like this:

string location = "India,Tamilnadu,Chennai,Annanagar";
string[] words = location.Split(',');

Array.Reverse(words);

string newlocation = String.Join(",", words);

Console.WriteLine(newlocation); // Annanagar,Chennai,Tamilnadu,India

这篇关于如何扭转字的顺序查询或c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 09:49