我希望“manish”字符串转换为“anishm” c#中的逻辑是什么 [英] i want to "manish" string to conver "anishm" what is logic in c#
本文介绍了我希望“manish”字符串转换为“anishm” c#中的逻辑是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用系统;
使用 System.Collections.Generic;
使用 System.Linq;
使用 System.Text;
使用 System.Threading.Tasks;
命名空间 string2
{
class Program
{
静态 void Main( string [] args)
{
Console.WriteLine( 输入值跨度>);
string str = Console.ReadLine();
char [] ch = str.ToCharArray();
char [] ch1 = new char [ch.Length];
int i;
char temp;
for (i = 0 ; i < ; ch.Length - 1 ; i ++)
{
temp = ch [i];
ch1 [i] = ch [i + 1 ];
Console.Write(ch1 [i]);
if (ch1.Length< 1)
{
return ch;
}
}
Console.ReadKey();
}
}
}
解决方案
尝试:
< pre lang =c#> string input = manish 跨度>;
string output = input.Substring( 1 )+ input.Substring( 0 , 1 );
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace string2
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("enter the value");
string str = Console.ReadLine();
char[] ch = str.ToCharArray();
char[] ch1 = new char[ch.Length];
int i;
char temp;
for (i = 0; i < ch.Length - 1; i++)
{
temp = ch[i];
ch1[i] = ch[i + 1];
Console.Write(ch1[i]);
if (ch1.Length <1)
{
return ch;
}
}
Console.ReadKey();
}
}
}
解决方案
Try:
string input = "manish"; string output = input.Substring(1) + input.Substring(0,1);
这篇关于我希望“manish”字符串转换为“anishm” c#中的逻辑是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文