PDA

View Full Version : سوال: عوض کردن جای کلمات



ZivehDesigne
سه شنبه 24 دی 1392, 23:40 عصر
سلام دوستان!

من تو یه برنامه باید جای کلمات را عوض کنم مثلا: Ahmad Safavi = Safavi Ahmad

حالا تکه کد زیر رو نوشتم نمی دونم کجا اشکال داره فقط کلمه اولو تکرار میکنه


string M;
string S;
S =null;
M = TextBox1.Text;
string[] a = M.Split();
string[] b = new string[a.Length];
for (int i=a.Length-1;i>=0;i--)
{
for (int j=0;j<=a.Length-1;j++)
{
b[j]=a[i];
}
}

for (int i = 0; i <= a.Length-1; i++)
{
S = S + " " + b[i];
}
TextBox2.Text =S;
ممنون میشم راهنماییم کنید...

ahmad156
چهارشنبه 25 دی 1392, 00:07 صبح
string first = "In the name of God";
string[] temp = first.Split(' ');
int count = temp.Length;
string output = string.Empty;
while (count!=0)
{
output += temp[count-1] + " ";
count--;
}

ZivehDesigne
چهارشنبه 25 دی 1392, 00:24 صبح
string first = "In the name of God";
string[] temp = first.Split(' ');
int count = temp.Length;
string output = string.Empty;
while (count!=0)
{
output += temp[count-1] + " ";
count--;
}


دمت گرم دوست عزیز 1 دنیا ممنون!