Ful*_*rum 1 c# visual-studio-2010
我在文本框中有这个文字: mytextvariable.mytext
如何在点之前仅提取文本?
例如:textbox1 = mytext.text
按钮单击
textbox2 =没有.text的mytext
只需使用简单的字符串操作
string text = textBox1.Text;
int firstDot = text.IndexOf('.');
if (firstDot != -1)
{
string firstPart = text.Susbtring(0, firstDot);
textBox2.Text = firstPart;
}
else
{
// Handle case with no dot
}
Run Code Online (Sandbox Code Playgroud)
从根本上说,这与来自文本框的文本无关 - 它只是一个字符串,真的.
| 归档时间: |
|
| 查看次数: |
1584 次 |
| 最近记录: |