DataTable.Clone 方法

博客介绍了 DataTable.Clone 方法,该方法可克隆 DataTable 的结构,包括架构和约束,返回与当前 DataTable 有相同架构的新 DataTable。还给出了 Visual Basic、C#、C++ 的示例,同时说明了该方法的平台要求。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

.NET Framework 类库 

DataTable.Clone 方法

克隆 DataTable 的结构,包括所有 DataTable 架构和约束。

[Visual Basic]
Public Overridable Function Clone() As DataTable
[C#]
public virtual DataTable Clone();
[C++]
public: virtual DataTable* Clone();
[JScript]
public function Clone() : DataTable;
返回值

新的 DataTable,与当前的 DataTable 具有相同的架构。

备注
注意   如果这些类已经过派生,则副本也具有相同的派生类。
示例

[Visual Basic, C#, C++] 以下示例创建 DataTable 对象架构的复本。

[Visual Basic] 
Private Sub GetClone(ByVal myDataTable As DataTable)
    ' Get a clone of the original DataTable.
    Dim cloneTable As DataTable
    cloneTable = myDataTable.Clone()
    ' Insert code to work with clone of the DataTable.
 End Sub

[C#] 
private void GetClone(DataTable myDataTable){
    // Get a clone of the original DataTable.
    DataTable cloneTable;
    cloneTable = myDataTable.Clone();
    // Insert code to work with clone of the DataTable.
 }

[C++] 
private:
void GetClone(DataTable* myDataTable){
    // Get a clone of the original DataTable.
    DataTable* cloneTable;
    cloneTable = myDataTable->Clone();
    // Insert code to work with clone of the DataTable.
 }

[JScript] 没有可用于 JScript 的示例。若要查看 Visual Basic、C# 或 C++ 示例,请单击页左上角的“语言筛选器”按钮 语言筛选器

要求

平台: Windows 98, Windows NT 4.0, Windows ME, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 系列, .NET Framework 精简版

请参见

DataTable 类 | DataTable 成员 | System.Data 命名空间

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值