【发布时间】:2015-02-25 09:49:12
【问题描述】:
我必须设计一个接口来读取字符串并在给定字符串中找到(m、n 和 t 字母表)中任何一个字符的第一次出现
输出应该是这样的
输入:电脑
输出:列表中的第一个字符是“m”,出现在“计算机”的第 3 位。它是单词中 8 个字符中的第 3 个
我的代码:
string a = TextBox1.Text;
string result = "";
int ss = a.Length;
string[] m = {"t","n","m"};
int b;
//search for m or n or t and assign it to string result
b = a.IndexOf (result) + 1;
string str = a.Substring(b-1,1);
Label2.Text = "The first character from the list is " + str +
" occurred at position " + b.ToString() + " in "+ a +".
it is the "+ b.ToString() + "rd of " + ss.ToString() +
" characters in the word.";
如何搜索 m 或 n 或 t 并将其分配给字符串结果?!!!
【问题讨论】:
-
那么问题是什么?
-
@MokshShah 如何搜索 m 或 n 或 t 并将其分配给字符串结果
标签: c# asp.net .net arrays string