本文介绍了合并两个表而不移动列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我试图用Merge方法合并两个DataTable对象,它似乎表现得这样: A = | col1 | col2 | | a1 | b1 | | a2 | b2 | | a3 | b3 | | a4 | b4 | B = | col3 | col4 | | c1 | d1 | | c2 | d2 | | c3 | d3 | | c4 | d4 | A.Merge(B)给出以下结果: | col1 | col2 | col3 | col4 | | a1 | b1 | | | | a2 | b2 | | | | a3 | b3 | | | | a4 | b4 | | | | | | c1 | d1 | | | | c2 | d2 | | | | c3 | d3 | | | | c4 | d4 | 我想要的是: | col1 | col2 | col3 | COL4 | | a1 | b1 | c1 | d1 | | a2 | b2 | c2 | d2 | | a3 | b3 | c3 | d3 | | a4 | b4 | c4 | d4 | 在我的研究中,我可以找到不同的解决方案,例如创建空列,浏览行并逐个添加它们一个但是第一个,这在性能方面不是一个好方法。 任何人都可以帮忙吗?解决方案 Hi,I have tried to Merge two DataTable objects with the method Merge and it seems that it behaves this way:A = |col1|col2| |a1 |b1 | |a2 |b2 | |a3 |b3 | |a4 |b4 |B = |col3|col4| |c1 |d1 | |c2 |d2 | |c3 |d3 | |c4 |d4 |A.Merge(B) gives the following result:|col1|col2|col3|col4||a1 |b1 | | ||a2 |b2 | | ||a3 |b3 | | ||a4 |b4 | | || | |c1 |d1 || | |c2 |d2 || | |c3 |d3 || | |c4 |d4 |What I want to have is:|col1|col2|col3|col4||a1 |b1 |c1 |d1 ||a2 |b2 |c2 |d2 ||a3 |b3 |c3 |d3 ||a4 |b4 |c4 |d4 |In my researches, I could find different solutions such as creating empty columns, browsing rows and adding them one by one but first, this is cannot be a good way in term of performance.Can any one help with this? 解决方案 这篇关于合并两个表而不移动列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-09 14:46