我正在使用VB .NET,我知道Union通常使用ByRef,但在VB中,字符串通常被处理为好像它们是原始数据类型.
因此,问题在于:
- Sub Main()
- Dim firstFile,secondFile As String(),resultingFile As New StringBuilder
- firstFile = My.Computer.FileSystem.ReadAllText(My.Computer.FileSystem.SpecialDirectories.Desktop & "\1.txt").Split(vbNewLine)
- secondFile = My.Computer.FileSystem.ReadAllText(My.Computer.FileSystem.SpecialDirectories.Desktop & "\2.txt").Split(vbNewLine)
- For Each line As String In firstFile.Union(secondFile)
- resultingFile.AppendLine(line)
- Next
- My.Computer.FileSystem.WriteAllText(My.Computer.FileSystem.SpecialDirectories.Desktop & "\merged.txt",resultingFile.ToString,True)
- End Sub
1.txt包含:
一个
b
C
d
Ë
2.txt包含:
b
C
d
Ë
F
G
H
一世
Ĵ
运行代码后,我得到:
一个
b
C
d
Ë
b
F
G
H
一世
Ĵ
任何使联盟功能都像数学对应的建议?