如何用字符串函数删除字符? [英] how to remove character with string function?

查看:134
本文介绍了如何用字符串函数删除字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

函数中有字符串来...



这些就像这些01 02 03 ...... 09 10 11 12 .... 31个字符串



我想在01 ...... 09前面删除零,所以01必须是1,02 2,03 3 .... .09 9



但是10 11 12我不打算......





如何删除零? 01 1但11 12 .... 31将不会触及

解决方案

以您选择的格式转到 String.Split( )方法,然后调用convert转换为整数并将其存储在新的整数列表中。


最简单的方法是调用 myStream.TrimStart(''0''); 请参阅:

http://msdn.microsoft.com/en-us/library/system.string.trimstart.aspx [ ^ ]。



但是,重要的是要理解你不能从字符串中删除任何东西,因为字符串是不可变的。所有字符串方法修改字符串实际上都不会修改任何字符串对象,它们会创建一个包含适当内容的全新字符串。



-SA

there are strings from a function comes...

these comes like these 01 02 03 ......09 10 11 12..... 31 strings

I want to remove zero in front of 01......09 so 01 must be 1 ,02 2, 03 3.....09 9

but 10 11 12 I will not thouch...


how to remove zero? 01 1 but 11 12 ....31 will not thouch

解决方案

In the format you have chosen Id go for String.Split(" ") method, and then call convert to integer and store it in a new list of integers.


The easiest way is to call myStream.TrimStart(''0''); please see:
http://msdn.microsoft.com/en-us/library/system.string.trimstart.aspx[^].

However, in''s important to understand that you cannot remove anything from a string, as strings are immutable. All string methods "modifying" string actually don''t modify any string object, they create a brand new string with appropriate content.

—SA


这篇关于如何用字符串函数删除字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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