C#字符串索引concacinate [英] C# string index concacinate

查看:79
本文介绍了C#字符串索引concacinate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我需要帮助合并两个stings索引`


for examble 


string strs1 =" Hello" ;;


string str2 =" World";


我需要输出如下:HWeolrllod 


意思是不断地从每个字符串中添加索引,但我不知道它的完美方法是什么。


解决方案

试试这个:


 string str1 =" Hello" ;; 
string str2 =" World" ;;
string result = string.Concat(str1.Zip(str2,(c1,c2)=> string.Concat(c1,c2)));
Console.WriteLine(结果);


 


如果字符串较长,则不包括其尾部。




hello, i need help in combining two stings indexes`

for examble 

string strs1 = "Hello";

string str2 = "World";

i need the output to be like so : HWeolrllod 

meaning adding the indexes from each string continually but i do not know what is the perfect method for it.

解决方案

Try this:

string str1 = "Hello";
string str2 = "World";
string result = string.Concat( str1.Zip( str2, ( c1, c2 ) => string.Concat( c1, c2 ) ) );
Console.WriteLine( result );

 

If a string is longer, its tail is not included.



这篇关于C#字符串索引concacinate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆