使用String.Split:分隔符字符 [英] Using String.Split: Delimiter Character

查看:104
本文介绍了使用String.Split:分隔符字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎string.split命令中的分隔符必须小于ascii 128.例如,它似乎不接受‡(135)或¶(182)等字符。



有没有办法让VB.Net接受其中一个字符?

It seems that the delimiter character in the string.split command has to be less the ascii 128. For example, it does not seem to accept characters such as ‡ (135) or ¶ (182).

Is there any way to get VB.Net to accept one of these characters?

推荐答案

你吓死我了。 :-)

好​​吧,不是这样;事实上,我首先假设我不应该相信你,但是......这听起来很麻烦,所以我测试了它。 当然,你所说的不是真的:一切都适用于任何分隔符,包括你在例子中提到的字符。我使用.NET版本3.5进行测试,这已经够老了。



你需要注意你的测试技巧。 :-)







您对文件的看法。 ReadAllLines 不是真的。 (再次!)

请更加小心。请参阅下面的评论。在一般情况下,您可以使用另一个 File.ReadAllLines 方法,使用编码:

http://msdn.microsoft.com/en-us/library/bsy4fhsa%28v=vs.110%29.aspx [ ^ ]。



但如果你的问题是'^'(它不是!)那么无论如何都会无关紧要。



看,你需要1)有条不紊地做你的工作; 2)使用调试器; 3)了解Unicode是什么以及它是如何工作的 - 现在写一下你没有线索。



-SA
You scared me to death. :-)
Well, not quite so; in fact, I first assumed that I rather should not trust you, but… it sounds quite troublesome enough, so I tested it. Of course, what you say turns out to be not true: everything works correctly with any delimiters, including the characters you mentioned in your example. I used .NET versions 3.5 for the test, which is old enough.

You need to take care about your testing skills. :-)



What you say about File.ReadAllLines is not true. (Again!)
Please, be more careful. Please see my comment below. In general case, you can use another File.ReadAllLines method, with encoding:
http://msdn.microsoft.com/en-us/library/bsy4fhsa%28v=vs.110%29.aspx[^].

But if your problem was '^' (it is not!) it would be irrelevant anyway.

Look, you need to 1) do your work methodically; 2) use the debugger; 3) learn what Unicode is and how it works — write now you don't have a clue.

—SA


这篇关于使用String.Split:分隔符字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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