本文介绍了replace()方法问题???的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我搜索一个字符串,看看是否有描述字样。如果是,请将其替换为

,并附上描述。出于某种原因,如果它找到Desc,在单词

" Description"它取代了Desc。其中一部分具有描述因此具有描述的最终结果。有没有办法让

replace()方法只在整个字符串是Desc的情况下才能替换。只有而不是

" Desc *" ?希望这是有道理的。提前致谢。


if(" Text" == dcSource.ColumnName.ToString())

{

string changeContent = drSource [dcSource.ColumnName] .ToString();

changeContent = changeContent.Replace(" Desc"," Description");

drSource [dcSource。 ColumnName] = changeContent;

}

-

通过DotNetMonster.com发布消息

Hi all,

I searching a string to see if "Desc" resides in it, if so then replace it
with "Description". For some reason if it finds "Desc" in the word
"Description" it replaces the "Desc" part of it with "Description thus having
the final outcome of "Descriptionription". Is there a way to have the
replace() method only replace if the entire string is "Desc" only and not
"Desc* " ? Hope this makes sense. Thanks in advance.

if( "Text" == dcSource.ColumnName.ToString() )
{
string changeContent = drSource[dcSource.ColumnName].ToString();
changeContent = changeContent.Replace("Desc", "Description");
drSource[dcSource.ColumnName] = changeContent;
}
--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...sharp/200511/1

推荐答案




-

Larry Lard

回复团体请



--
Larry Lard
Replies to group please





-

通过DotNetMonster.com发布的消息


这篇关于replace()方法问题???的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 16:33