就是获得 DataTable 是属于那个 DataSet的 这样可以获得这个DataSet中的其他DataTable像Form有MdiParent MdiChildren,可以找到其他的Form 指针而已,是只读的 :) -----MSDN------ Gets the DataSet that this table belongs to. [C#]public DataSet DataSet {get;}Res If a control is data bound to a DataTable, and the table belongs to a DataSet, you can get to the DataSet through this property.
就是获得 DataTable 是属于那个 DataSet的 这样可以获得这个DataSet中的其他DataTable像Form有MdiParent MdiChildren,可以找到其他的Form 指针而已,是只读的 :) -----MSDN------ Gets the DataSet that this table belongs to. [C#] public DataSet DataSet {get;}Res If a control is data bound to a DataTable, and the table belongs to a DataSet, you can get to the DataSet through this property.
我說在.Net Framework內部﹗﹗﹗這個實現方式我急需呀~~~~
他的内部有Private的DataSet,在Sub New的时候就赋过值了。
然后又有个ReadOnly的DataSet属性,返回的是那个Private的DataSet
这样可以获得这个DataSet中的其他DataTable像Form有MdiParent MdiChildren,可以找到其他的Form
指针而已,是只读的 :)
-----MSDN------
Gets the DataSet that this table belongs to.
[C#]public DataSet DataSet {get;}Res
If a control is data bound to a DataTable, and the table belongs to a DataSet, you can get to the DataSet through this property.
这样可以获得这个DataSet中的其他DataTable像Form有MdiParent MdiChildren,可以找到其他的Form
指针而已,是只读的 :)
-----MSDN------
Gets the DataSet that this table belongs to.
[C#]
public DataSet DataSet {get;}Res
If a control is data bound to a DataTable, and the table belongs to a DataSet, you can get to the DataSet through this property.
理解不很正確。那么再問mwenyuan(William Ma) : 可是內部那個 private DataSet它是怎么賦值的﹐因為它必須把外部那個
實際DataSet賦給它﹐然而他是private的﹐所以無法賦值得。
300分求解 300分求解 300分求解 300分求解
300分求解 300分求解 300分求解 300分求解
300分求解 300分求解 300分求解 300分求解
300分求解 300分求解 300分求解 300分求解
300分求解 300分求解 300分求解 300分求解
300分求解 300分求解 300分求解 300分求解
.method assembly hidebysig instance void
SetDataSet(class System.Data.DataSet dataSet) cil managed
{
// Code size 68 (0x44)
.maxstack 3
.locals init (class System.Data.DataColumnCollection V_0,
int32 V_1)
IL_0000: ldarg.0
IL_0001: ldfld class System.Data.DataSet System.Data.DataTable::dataSet
IL_0006: ldarg.1
IL_0007: beq.s IL_0043
IL_0009: ldarg.0
IL_000a: ldarg.1
IL_000b: stfld class System.Data.DataSet System.Data.DataTable::dataSet
IL_0010: ldarg.0
IL_0011: call instance class System.Data.DataColumnCollection System.Data.DataTable::get_Columns()
IL_0016: stloc.0
IL_0017: ldc.i4.0
IL_0018: stloc.1
IL_0019: br.s IL_002b
IL_001b: ldloc.0
IL_001c: ldloc.1
IL_001d: callvirt instance class System.Data.DataColumn System.Data.DataColumnCollection::get_Item(int32)
IL_0022: callvirt instance void System.Data.DataColumn::OnSetDataSet()
IL_0027: ldloc.1
IL_0028: ldc.i4.1
IL_0029: add
IL_002a: stloc.1
IL_002b: ldloc.1
IL_002c: ldloc.0
IL_002d: callvirt instance int32 System.Data.InternalDataCollectionBase::get_Count()
IL_0032: blt.s IL_001b
IL_0034: ldarg.0
IL_0035: call instance class System.Data.DataSet System.Data.DataTable::get_DataSet()
IL_003a: brfalse.s IL_0043
IL_003c: ldarg.0
IL_003d: ldnull
IL_003e: stfld class System.Data.DataView System.Data.DataTable::defaultView
IL_0043: ret
} // end of method DataTable::SetDataSet
.field private class System.Data.DataSet dataSet
.property instance class System.Data.DataSet
DataSet()
{
.custom instance void [System]System.ComponentModel.BrowsableAttribute::.ctor(bool) = ( 01 00 00 00 00 )
.custom instance void [System]System.ComponentModel.DesignerSerializationVisibilityAttribute::.ctor(valuetype [System]System.ComponentModel.DesignerSerializationVisibility) = ( 01 00 00 00 00 00 00 00 )
.custom instance void System.Data.DataSysDescriptionAttribute::.ctor(string) = ( 01 00 15 44 61 74 61 54 61 62 6C 65 44 61 74 61 // ...DataTableData
53 65 74 44 65 73 63 72 00 00 ) // SetDescr..
.get instance class System.Data.DataSet System.Data.DataTable::get_DataSet()
} // end of property DataTable::DataSet
老兄﹐你牛﹐可不可以把這些IL翻譯出來﹐翻譯成C#,分一定給。
在DataTable.cs中:
internal DataSet dataSet;
public DataSet DataSet {
get { return dataSet; }
}
这就说明DataSet属性返回的是内部的dataSet,而dataSet并非private,而是internal,这说明外部虽然无法访问,但在System.Data.dll中的其他过程,如DataTableCollection是可以访问的!
这就是DataTableCollection.cs中的代码:
public virtual void Add (DataTable table)
{
list.Add (table);
table.dataSet = dataSet;
tables[table.TableName] = table;
}
这就是DataSet.Tables.Add的代码,你可以很清楚地发现,它直接修改了
DataTable的dataSet字段,它是internal,对外部看不见,但可以在
System.Data.dll中轻松访问
回复人: Ninputer(装配脑袋)
说的对,用set and get来取值,赋值
[email protected] 謝謝﹗不過如果是internal﹐那么在object broswer可以看到的﹐比如 DataRow的建
構子就是internal的﹐所以我們無法在assembly外面實例化DataRow對象。可是伙看DataTable對象﹐是沒有什么方法屬性是internal修飾過的。如果你說的正確﹐我想我在object broswer中也可以看見一個dataSet和一個DataSet。我明天自己調試一下試試.
可不可以告訴哪里可以得到.net framework的代碼﹐據說微軟公布了100萬行.
另外我看的是Mono 0.12的源代码,并不是MS德源代码,但我想原理是一样的
你可以到www.go-mono.com上下载
http://www.go-mono.com/archive/mcs-0.12.tar.gz
解开以后就可以在里面的class目录中看到源代码,如果想编译他还不行,你可以参考Mono网站上的说明(需要cygwin才能编译)。
微软并没有公布CLR的源代码,但可以返汇编,就像CForce做的那样
//to bigtree21cn(寵物) :微软的代码没有这部分内容,只有最基础的mscorlib.dll部分
namespace System.Data
{
class DataTable:MarshalByValueComponent, IListSource,ISupportInitialize, ISerializable
{
//......
private System.Data.DataSet dataSet;
private System.Data.DataColumnCollection columnCollection;
//......
public DataSet DataSet
{
get
{
return this.dataSet;
}
}
//......
public DataColumnCollection Columns
{
get
{
if (this.columnCollection == null)
this.columnCollection = new DataColumnCollection(this);
return this.columnCollection;
}
} internal void SetDataSet(DataSet dataSet)
{
System.Data.DataColumnCollection dataColumnCollection;
int i; if (this.dataSet != dataSet)
{
this.dataSet = dataSet;
dataColumnCollection = this.Columns;
i = 0;
while (i< dataColumnCollection.Count)
{
dataColumnCollection.Item(i).OnSetDataSet();
i++;
}
if (this.DataSet != null)
this.defaultView = null;
}
}
//......
}
}
似乎更安全一些
帮忙看一下http://www.csdn.net/expert/topic/789/789584.xml?temp=.9744532
Ninputer(装配脑袋)
CForce()
參與﹐結帳。再問哪里有mscorlib.dll源代碼。
to bigtree21cn(寵物) :那些代码微软网站有得下;你的专家分不够,所以不能给高分,最多只能给100分。你要么再开帖子,要么等你有星星才加分