【问题标题】:.net split command acting strange.net split 命令表现得很奇怪
【发布时间】:2013-02-22 15:40:30
【问题描述】:

我有这两行代码:

Dim templine() = Alfalines(i).Split(DataGridView1.Rows(s).Cells(1).Value)  
textlines(i) = Alfaline(0) + DataGridView1.Rows(s).Cells(language_row).Value + Alfaline(1)

第一行的DataGridView1.Rows(s).Cells(1).Value 在错误发生时的值为"Form2A186_1"Alfalines(i)" Caption = "Form2A186_1"

问题是 split 命令将 F 识别为分隔符并将字符串拆分为:

0: "Caption    =   "    
1: "orm2A186_1"

【问题讨论】:

  • OPTION STRICT 的设置是什么?开或关,我认为是关。

标签: .net vb.net string split


【解决方案1】:

我认为这里的问题是带有 on 参数的 String.Split() 方法仅将 char[] 作为其参数,而不是 string 或 string[],根据此处的文档: http://msdn.microsoft.com/en-us/library/system.string.split.aspx

所以为了按字符串分割,你应该使用这个重载:

Public Function Split ( _
    separator As String(), _
    options As StringSplitOptions _
) As String()

【讨论】:

  • MyString.Split(new String() {MySeparator},StringSplitOptions.None)
猜你喜欢
  • 2013-02-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-12-12
  • 2012-11-11
  • 1970-01-01
  • 1970-01-01
  • 2023-03-22
相关资源
最近更新 更多