如何在c#中拆分多个字母 [英] How to Split multiple letters in c#

查看:46
本文介绍了如何在c#中拆分多个字母的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

那里



在我的一次采访中;面试官要求写下一个程序



问:



有一个TextBox有这个预定义值为Val1!@#$%Val2!@#$%Val3!@#$ Val4!@#$%其中。



点击按钮他们想在标签中反转这个文字如下。



输出:Val4!@#$%Val3!@#$%Val2!@#$%Val1! @#$%





怎么做?



NB文字没有任何空间。他们都加入了。因此拆分功能不起作用



 <  < span class =code-leadattribute> asp:TextBox     ID   =  txt1   文字  =  Val1!@#$%Val2!@#$%Val3!@#$% Val4    runat   =  server    
< span class =code-attribute>
宽度 = 280px > Val1!@# $%Val2!@#$%Val3!@#$%Val4 < / asp:TextBox < span class =code-keyword>>
< / br >
< asp:Button ID = < span class =code-keyword> btnResult 文字 = GetResult runat = server

onclick = btnResult_Click / >
< / br >
< asp:标签 ID = result runat = 服务器 > < / asp:Label >

解决方案

%Val2!@#


%Val3!@#


VAL4!@#

Hi, there

In one of my interview; interviewer asked to write a program for following

Q :

There is a TextBox which having this predefined value as "Val1!@#$%Val2!@#$%Val3!@#$Val4!@#$%" in it.

On a button click they want to reverse this text in a label as follow.

Output : Val4!@#$%Val3!@#$%Val2!@#$%Val1!@#$%


How to do this?

N.B. Text don't having any space. They all are joined. So split function not working for this

<asp:TextBox ID="txt1" Text="Val1!@#$%Val2!@#$%Val3!@#$%Val4" runat="server" 

            Width="280px">Val1!@#$%Val2!@#$%Val3!@#$%Val4</asp:TextBox>
        </br>
        <asp:Button ID="btnResult" Text="GetResult" runat="server" 

            onclick="btnResult_Click" />
        </br>
        <asp:Label ID="result" runat="server"></asp:Label>

解决方案

%Val2!@#


%Val3!@#


Val4!@#


这篇关于如何在c#中拆分多个字母的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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