English 中文(简体)
在不知情的情况下从扼杀中去除特性
原标题:Remove a character from a string without knowing its position
  • 时间:2012-01-13 11:53:41
  •  标签:
  • c#-4.0

I want to remove a character ( . ) from a string without knowing its position. For example.

string test = "4.000";

但总是会发生变化。

感谢!

最佳回答

如果你只想消除这种性质的首次发生:

string newString = test.Remove(test.IndexOf(".", 1));

如果你想要删除<><>all这种性质的事件:

string newString = test.Replace(".", "");
问题回答

http://msdn.microsoft.com/en-us/library/fk49wtc1.aspx”rel=“nofollow”>String.Replace

string stringToReplace = ".";
string test = "4.000";
test = test.Replace(stringToReplace, "");




相关问题
Howto get started with C# 4.0 and .NET 4.0?

I don t want to download Visual Studio 2010. How can I start studying (not developing real applications) C# 4.0 and .NET 4.0 with just a text editor? Can I just download C# 4.0 compiler and .NET 4.0 ...

Mocking Framework with C# 4.0 Support?

Anybody know of a mocking framework that supports C# 4.0? Doesn t matter which one ATM, just need something that will work.

Unit Testing interface contracts in C#

Using the Code Contracts tools available in VS2010 Beta 2, I have defined an interface, a contract class for that interface and two classes that implement the interface. Now when I come to test the ...

How to Iterate Through Array in C# Across Multiple Calls

We have an application where we need to de-serialize some data from one stream into multiple objects. The Data array represents a number of messages of variable length packed together. There are no ...

IronPython ScriptRuntime equivalent to CPython PYTHONPATH

The following import works inside ipy.exe prompt but fails using IronPython ScriptRuntime inside a C# 4.0 program. import ConfigParser C# code: using System; using System.Collections.Generic; using ...

i cant understand the following code

Matrix<float> trainData2 = trainData.GetRows(intVar >> 1, intVar, 1); intVar is integer type... please help me to understand this code.

热门标签