数据集?属性?值? [英] Datasets? Properties? Values?

查看:75
本文介绍了数据集?属性?值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,


我一直在使用一个应用程序,它将数据集发送到其他表单

,这些是从各个DLL调用的。


我注意到,传递给另一个表单的数据集在更改时,

会更改所有表单中的数据集。

但是,如果你将一个字符串发送到其他表格,那么每个表格上的价值都是独立的

.. IE


从表格中调用表格DLL:


Dim ADataset As New DataSet()

Dim FormNumber As String


Public Property RefDataset()作为DataSet

获取

返回RefDataset

结束获取

设置(ByVal值为数据集)

ADataset =价值

结束集

结束物业


公共财产WhatForm()作为字符串

获取

返回WhatForm

结束获取

设置(ByVal值为字符串)

FormNumber =价值

结束集

结束物业


如果我更改''ADataset'内的数据,主应用程序和被叫

表格'的数据集会一起变化(所有这些都是好的和好的

我需要它。

但是如果我更改FormNumber只有被调用的表单''的FormNumber更改和

不是全部。

这是正常的吗?这是否与数据集的创建方式有什么关系?
创建的数据集使其适用于数据集而不是其他值?


我们将非常感谢任何建议,


谢谢,

Chuck

解决方案

虽然string是引用类型,.NET已经包含了处理

它的功能将是一个值类型。


传递一个引用类型(如数据集) value只是将指针

传递给内存中的特定对象。您无法更改它指向的对象数据集,但您可以更改其内容。在您的情况下,当数据集中更改了

内容,并且它是按值传递时,

更改将提交到内存中的数据集对象。 br />

对于字符串的情况,每个项目都有自己的

字符串副本,因为它的行为类似于值类型。顺便说一下,VB.NET还支持

旧的函数名值吗?


公共属性RefDataset()As DataSet

获取

返回RefDataset

结束获取

设置(ByVal值为数据集)

ADataset = Value

结束集

结束物业


get属性的新方法应该返回私有变量


Public Property RefDataset()As DataSet

获取

返回ADataset ***

结束获取

Set (ByVal Value As DataSet)

ADataset =价值

结束集

结束物业

" Charles A. Lackman" <章***** @ CreateItSoftware.net>写在消息

新闻:em ************** @ TK2MSFTNGP09.phx.gbl ...

你好,
我一直在使用一个应用程序,它将数据集发送到从单个DLL调用的其他
表单。

我注意到,一个数据集是传递给另一种形式,当
改变时,改变所有形式的数据集。
但是,如果你将字符串发送到其他形式,那么每个表格上的值是
独立。 .IE

从DLL调用表单:

Dim ADataset作为新数据集()
Dim FormNumber作为字符串

公共属性RefDataset ()作为DataSet
获取
返回RefDataset
结束获取
设置(ByVal值为DataSet)
ADataset = Value
结束集
结束物业

公共财产WhatForm()作为字符串
获取
返回WhatForm
结束获取
设置(ByVal值为字符串)
FormNumber =价值
结束集
结束财产

如果我改变e''ADataset'中的数据'主应用程序'和被调用的
表单'的数据集一起变化(所有这些)这对于我需要的东西是好的和好的。
但是,如果我更改FormNumber,只有被调用的表单''FormNumber更改
而不是全部。
这是正常的吗?这是否与创建数据集如何使其适用于数据集而不是其他值有关?

任何建议都将不胜感激,

谢谢,
Chuck



对于字符串的情况,如果您希望它具有全局效果,请将其传递<通过引用获得


" Joey Callisay" < HC ****** @ codex-systems.com>在留言中写道

新闻:OJ ************** @ TK2MSFTNGP10.phx.gbl ...

虽然字符串是参考类型,.NET已经包含了对它的处理,所以它的功能将是一个值类型。

按值传递引用类型(如数据集)只是传递
指向内存中特定对象的指针。您无法更改它指向的对象数据集,但您可以更改其内容。在您的情况下,当数据集中的内容发生更改并且按值传递时,
更改将提交到内存中的数据集对象。

在字符串的情况下,每个项目都有自己的
字符串副本,因为它的行为类似于值类型。顺便说一下,VB.NET还支持旧的函数名值吗?

公共属性RefDataset()作为DataSet
获取
返回RefDataset
结束获取
设置(ByVal值为数据集)
ADataset =值
结束集
结束属性

get属性的新方法应该返回私有变量

公共财产RefDataset()作为数据集
获取
返回ADataset ***
结束获取
设置(ByVal值为数据集)
ADataset = Value
End Set
End property

" Charles A. Lackman" <章***** @ CreateItSoftware.net>在消息中写道
新闻:em ************** @ TK2MSFTNGP09.phx.gbl ...

你好,
我一直在使用一个应用程序,它将数据集发送到其他


表单

,这些表单是从单个DLL中调用的。

我已经注意到,传递给另一个表单的数据集,当


发生变化时,

会更改所有表单中的数据集。
但是,如果发送一个字符串到其他表单,每个表单上的值
独立

.. IE

从DLL调用表单:
Dim FormNumber作为字符串

公共属性RefDataset()作为数据集
获取
返回RefDataset 结束获取
设置(ByVal值为数据集)
ADataset =值
结束集
结束属性

公共属性WhatForm()As String 返回Wha tForm
结束获取
设置(ByVal值为字符串)
FormNumber =值
结束集
结束属性

如果我更改数据在ADataset中,主应用程序和被称为
形式的数据集一起变化(所有这些),这对于我需要的东西来说是好的和精细的。但是,如果我更改FormNumber只有被调用的表单''FormNumber Changes


不是全部。
这是正常的吗?这是否与创建数据集如何使其适用于数据集而不是其他值有关?

任何建议都将不胜感激,

谢谢,
Chuck




Joey Callisay< hc ****** @ codex-systems.com>写道:

虽然字符串是一个引用类型,但.NET已经包含了对它的处理,因此它的函数将是一个值类型。




不是真的。这里的字符串没有什么特别之处。它只是一个

不可变对象,就像人们可以设计的任何其他不可变对象一样。


有*有* CLR处理字符串的方式一种特殊的方式,

但这不是其中之一。


-

Jon Skeet - < sk ***@pobox.com>
http://www.pobox.com /〜双向飞碟

如果回复小组,请不要给我发邮件


Hello,

I have been working with an application that sends a dataset to other forms
that are called from individual DLL''s.

I have noticed that, a dataset that is passed to another form, when changed,
changes the dataset in all of the forms.
But, if you send a string to the other forms, that the value is independant
on each form.. I.E.

Called Form from a DLL:

Dim ADataset As New DataSet()
Dim FormNumber As String

Public Property RefDataset() As DataSet
Get
Return RefDataset
End Get
Set(ByVal Value As DataSet)
ADataset = Value
End Set
End Property

Public Property WhatForm() As String
Get
Return WhatForm
End Get
Set(ByVal Value As String)
FormNumber = Value
End Set
End Property

If I change the data inside the ''ADataset'' the Main App''s and the called
form''s datasets change together (all of them) which is good and fine for
what I need it for.
But if I change the FormNumber only the called form''s FormNumber Changes and
not all of them.
Is this normal? Does this have something to do with how datasets are
created that makes it work for a Dataset and Not other values?

Any suggestions will be greatly appreciated,

Thank,
Chuck

解决方案

Although string is a reference type, .NET has already included handling on
it so its function will be that of a value type.

Passing a reference type (like a dataset) by value is just passing a pointer
to a particular object in memory. You cannot change the object dataset it
is pointing to yet you can change its contents. In your case, when the
contents are changed in the dataset, and it was being passed by value, the
changes will be committed to the dataset object in memory.

For the case of the string, each project will have their own copies of the
string since it behaves like a value type. Btw, does VB.NET still support
the old function name value?

Public Property RefDataset() As DataSet
Get
Return RefDataset
End Get
Set(ByVal Value As DataSet)
ADataset = Value
End Set
End Property

The new way for the get property should return the private variable

Public Property RefDataset() As DataSet
Get
Return ADataset ***
End Get
Set(ByVal Value As DataSet)
ADataset = Value
End Set
End Property
"Charles A. Lackman" <Ch*****@CreateItSoftware.net> wrote in message
news:em**************@TK2MSFTNGP09.phx.gbl...

Hello,

I have been working with an application that sends a dataset to other forms that are called from individual DLL''s.

I have noticed that, a dataset that is passed to another form, when changed, changes the dataset in all of the forms.
But, if you send a string to the other forms, that the value is independant on each form.. I.E.

Called Form from a DLL:

Dim ADataset As New DataSet()
Dim FormNumber As String

Public Property RefDataset() As DataSet
Get
Return RefDataset
End Get
Set(ByVal Value As DataSet)
ADataset = Value
End Set
End Property

Public Property WhatForm() As String
Get
Return WhatForm
End Get
Set(ByVal Value As String)
FormNumber = Value
End Set
End Property

If I change the data inside the ''ADataset'' the Main App''s and the called
form''s datasets change together (all of them) which is good and fine for
what I need it for.
But if I change the FormNumber only the called form''s FormNumber Changes and not all of them.
Is this normal? Does this have something to do with how datasets are
created that makes it work for a Dataset and Not other values?

Any suggestions will be greatly appreciated,

Thank,
Chuck



For the case of the string, if you want it to have a global effect, pass it
by reference
"Joey Callisay" <hc******@codex-systems.com> wrote in message
news:OJ**************@TK2MSFTNGP10.phx.gbl...

Although string is a reference type, .NET has already included handling on
it so its function will be that of a value type.

Passing a reference type (like a dataset) by value is just passing a pointer to a particular object in memory. You cannot change the object dataset it
is pointing to yet you can change its contents. In your case, when the
contents are changed in the dataset, and it was being passed by value, the
changes will be committed to the dataset object in memory.

For the case of the string, each project will have their own copies of the
string since it behaves like a value type. Btw, does VB.NET still support
the old function name value?

Public Property RefDataset() As DataSet
Get
Return RefDataset
End Get
Set(ByVal Value As DataSet)
ADataset = Value
End Set
End Property

The new way for the get property should return the private variable

Public Property RefDataset() As DataSet
Get
Return ADataset ***
End Get
Set(ByVal Value As DataSet)
ADataset = Value
End Set
End Property
"Charles A. Lackman" <Ch*****@CreateItSoftware.net> wrote in message
news:em**************@TK2MSFTNGP09.phx.gbl...

Hello,

I have been working with an application that sends a dataset to other


forms

that are called from individual DLL''s.

I have noticed that, a dataset that is passed to another form, when


changed,

changes the dataset in all of the forms.
But, if you send a string to the other forms, that the value is


independant

on each form.. I.E.

Called Form from a DLL:

Dim ADataset As New DataSet()
Dim FormNumber As String

Public Property RefDataset() As DataSet
Get
Return RefDataset
End Get
Set(ByVal Value As DataSet)
ADataset = Value
End Set
End Property

Public Property WhatForm() As String
Get
Return WhatForm
End Get
Set(ByVal Value As String)
FormNumber = Value
End Set
End Property

If I change the data inside the ''ADataset'' the Main App''s and the called
form''s datasets change together (all of them) which is good and fine for
what I need it for.
But if I change the FormNumber only the called form''s FormNumber Changes


and

not all of them.
Is this normal? Does this have something to do with how datasets are
created that makes it work for a Dataset and Not other values?

Any suggestions will be greatly appreciated,

Thank,
Chuck




Joey Callisay <hc******@codex-systems.com> wrote:

Although string is a reference type, .NET has already included handling on
it so its function will be that of a value type.



Not really. There''s nothing special about string here. It''s just an
immutable object, like any other immutable object one could design.

There *are* ways in which the CLR treats strings in a special manner,
but this isn''t one of them.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


这篇关于数据集?属性?值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆