在C#net的约会线上,
到目前为止,我使用的是:
string.Replace(@"","-")
但它还没有完成替换工作,有人能帮忙吗?
在C#net的约会线上,
到目前为止,我使用的是:
string.Replace(@"","-")
但它还没有完成替换工作,有人能帮忙吗?
stringing. replace
不修改字符串本身, 但返回新的字符串, 很可能您要丢弃新的字符串。 代之以这样做 :
myString= myString.Replace(@"","-");
顺便提一句,这种操作通常在手动用格式化的日期字符串乱涂的代码中看到。 在大多数情况下,做你想做的事( 也就是? ) 比做这种事情有更好的方法。
因为他们都说你需要拿回变量中的值。
因此,它应该是
val1= val1.Replace(@"","-");
或
val1= val1.Replace("\","-");
不仅如此,下面的一个人是行不通的
val1.Replace(@"","-");
用这种方式
oldstring = oldstring.Replace(@"","-");
查找 String. replace
返回类型。
它的函数返回一个已校正的字符串。 如果它只是更改了旧字符串, 那么它就会有一个 < code> 避免 返回类型 。
您也可以使用 :
myString = myString.Replace( \ , - ));
但只是让你知道,日期鞭笞通常是远期鞭笞/
,而不是反鞭笞。
正如其他人建议的那样,字符串. replace 不更新原始字符串对象, 但返回新的字符串 。
myString= myString.Replace(@"","-");
值得你理解的是,字符串在 C# 中是不可更改的, 基本上是为了让它变得安全。 关于字符串的更多细节以及为什么这些字符串是不可更改的, 请参看链接 < a href="http://msdn.microsoft.com/ en- us/library/ 362314fe. aspx" rel= “ nofollow noreferrer" >这里 和 < a href=" https://stackoverflow.com/ questions/2365272/ whis- net-string-is-immomobliable"。 < a>
相关问题
What is the use of `default` keyword in C#?
What is the use of default keyword in C#?
Is it introduced in C# 3.0 ?
Anyone feel like passing it forward?
I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs.
...
NSArray s, Primitive types and Boxing Oh My!
I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits.
Now here s the question: I feel really inclined to create some type of ...
C# Marshal / Pinvoke CBitmap?
I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class.
My import looks like this:
[DllImport(@"test.dll", CharSet = CharSet.Unicode)]
public static extern IntPtr ...
ADO.NET Entity Framework Association of Entities by Value Range
I have two EF entities. One has a property called HouseNumber. The other has two properties, one called StartHouseNumber and one called EndHouseNumber.
I want to create a many to many association ...
How to Use Ghostscript DLL to convert PDF to PDF/A
How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...
What is the most efficient keyvalue pair for ordering?
Since I cannot order my dictionary, what is the best way of going about taking key value pairs and also maintaing an index?
Linqy no matchy
Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control.
...
热门标签
- winforms
- combobox
- fogbugz
- java
- date
- internationalization
- asp.net
- iis
- url-rewriting
- urlrewriter
- c#
- enums
- ocaml
- haxe
- algorithm
- string
- viewstate
- .net
- c++
- c
- symbol-table
- mysql
- database
- postgresql
- licensing
- migration
- vb.net
- vb6
- declaration
- vb6-migration
- python
- psycopg2
- backup
- vmware
- virtualization
- gnu-screen
- authentication
- desktop
- excel
- xll
- cultureinfo
- regioninfo
- oracle
- client
- session
- download
- html
- virtual
- constructor
- scenarios
- perl
- full-text-search
- javascript
- ajax
- testing
- oop
- inheritance
- vim
- encapsulation
- information-hiding