更新时间:2023-02-21 17:59:22
尝试一下,
Try out this,
str1.substring(7);
除了现有答案外,还请注意:字符串是不可变的 .不管您使用字符串是什么,都永远不会删除",添加"或修改"字符串中的任何内容.而是创建了一个全新的字符串.重要的是要知道它的性能和对多线程的影响.例如,重复"+"是非常糟糕的.字符串的可变版本是System.Text.StringBuilder
.使用它来提高性能,只需使用System.Text.StringBuilder.ToString()
即可转换为字符串.—SA
Just a note, in addition to existing answers: strings are immutable. No matter you do with strings, you never "remove", "add" or "modify" anything it a string. Instead, a brand-new string is created. It''s important to know due to its performance and multithreading implications. For example, repeating "+" is very bad. A mutable version of string isSystem.Text.StringBuilder
. Use it for performance, convert to string simply usingSystem.Text.StringBuilder.ToString()
.—SA
***的办法是在分隔符:"
上分割字符串
the best thing would be to split your string on a seperator ":"
string s = "Name : Mohd Wasif";
string[] words = s.Split( '':''); // split string on seperator
Label.Text = words[1].Trim( ); // assign trimmed value without leading or trailing spaces