Jquery中文网 www.jquerycn.cn
Jquery中文网 >  脚本编程  >  Asp.net  >  正文 asp.net remove 删除字符串中指定位置的字符串片

asp.net remove 删除字符串中指定位置的字符串片

发布时间:2018-09-11   编辑:www.jquerycn.cn
jquery中文网为您提供asp.net remove 删除字符串中指定位置的字符串片等资源,欢迎您收藏本站,我们将为您提供最新的asp.net remove 删除字符串中指定位置的字符串片资源
remove 删除字符串中指定位置的字符串片段 第一参数是位置 第2个参数是长度
<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码如下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy2225')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy2225>


string str = "0123456789";          
Console.WriteLine(str.Remove(5));  
Console.WriteLine(str.Remove(5,1));

实例

Remove()
从指定位置开始删除指定数的字符

<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码如下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy1878')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy1878><%
 string str1="我是变形金刚的崇拜者之一";
 Response.Write(str1.Remove(6,4)); //结果为“我是变形金刚之一”
%>


使用 remove 从 array中移除项目.项目索引自动减1.

在Firefox浏览器中,调用remove时item 参数设置为 undefined 则移除第一个值为undefined的项目. 其它浏览器中,使用undefined值的item参数则没有效果.

下面的这示例展示了 remove 的使用方法.

JavaScript

<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码如下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy5202')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy5202>var a = ['a', 'b', 'c', 'd', 'e'];
Array.remove(a, 'c');
// 结果返回: "a,b,d,e"
document.write(a,"</p>");
Array.removeAt(a, 2);
// 结果返回//View the results: "a,b,e"
document.write(a,"</p>");

您可能感兴趣的文章:
asp.net remove 删除字符串中指定位置的字符串片
php字符串函数有哪些
php删除字符串第一个字符的方法
PHP中字符串处理的一些常用函数
python怎么删除字符串中的指定字符
PHP中常用的18个字符串函数
javascript中substr,substring,slice,splice的区别分析
C#基类应用--字符串处理类
php字符串删除前几个字符的方法
详解JavaScript的splice()方法

[关闭]