结构与类 [英] Structures Vs. Classes

查看:86
本文介绍了结构与类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到许多程序员使用类来存储有关这样的数据,例如:


类客户

.....电话

.... ID

....地址


结束课...... 。


在VB.net中,如果你不打算使用这种类型的

数据,结构是否更有意义功能/程序等等?

这只是旧式做事方式的一个拐点还是有一个好的

理由这样做?


-Peter

I''ve noticed that many programmers use classes to store data about such
things like:

Class Customers
.....Phone
....ID
....Address

End Class....

In VB.net, does a ''structure'' make more sense for storing this type of
data, if your not going to be using functions/Proceedures and such?
Is this just a crutch of the old way of doing things or is there a good
reason to do this?

-Peter

推荐答案

" pmclinn" < PE *** @ mclinn.com> schrieb:
"pmclinn" <pe***@mclinn.com> schrieb:
我注意到很多程序员使用类来存储关于这样的事情的数据:

类客户
....电话
... ID
...地址

结束课....

在VB.net中,做一个''结构' 如果你不打算使用函数/程序等等,那么存储这种类型的数据会更有意义吗?
这只是旧的做事方式的一个拐点还是有一个好的
有理由这样做吗?
I''ve noticed that many programmers use classes to store data about such
things like:

Class Customers
....Phone
...ID
...Address

End Class....

In VB.net, does a ''structure'' make more sense for storing this type of
data, if your not going to be using functions/Proceedures and such?
Is this just a crutch of the old way of doing things or is there a good
reason to do this?




见(完整主题):


< URL:http:// www.google.de/groups?threadm=8z%25Kb.2347%24d27.1979%40news-binary.blueyonder.co.uk>


-

MS Herfried K. Wagner

MVP< URL:http://dotnet.mvps.org/>

VB< URL:http:// dotnet .mvps.org / dotnet / faqs />



See (complete thread):

<URL:http://www.google.de/groups?threadm=8z%25Kb.2347%24d27.1979%40news-binary.blueyonder.co.uk>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>


" pmclinn" < PE *** @ mclinn.com> schrieb:
"pmclinn" <pe***@mclinn.com> schrieb:
我注意到很多程序员使用类来存储关于这样的事情的数据:

类客户
....电话
... ID
...地址

结束课....

在VB.net中,做一个''结构' 如果你不打算使用函数/程序等等,那么存储这种类型的数据会更有意义吗?
这只是旧的做事方式的一个拐点还是有一个好的
有理由这样做吗?
I''ve noticed that many programmers use classes to store data about such
things like:

Class Customers
....Phone
...ID
...Address

End Class....

In VB.net, does a ''structure'' make more sense for storing this type of
data, if your not going to be using functions/Proceedures and such?
Is this just a crutch of the old way of doing things or is there a good
reason to do this?




见(完整主题):


< URL:http:// www.google.de/groups?threadm=8z%25Kb.2347%24d27.1979%40news-binary.blueyonder.co.uk>


-

MS Herfried K. Wagner

MVP< URL:http://dotnet.mvps.org/>

VB< URL:http:// dotnet .mvps.org / dotnet / faqs />



See (complete thread):

<URL:http://www.google.de/groups?threadm=8z%25Kb.2347%24d27.1979%40news-binary.blueyonder.co.uk>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>


一些程序员拒绝使用结构,因为他们认为你不能使用
说你永远不需要一个功能。因此,如果他们只是将它作为一个

类开始,这将在以后永远不会成为问题。说实话

我在C ++中遇到这个问题,因为这个原因,我必须修改一些代码才能将几个结构改为类。因此,我喜欢使用

的想法让所有东西都成为一个类。


" pmclinn" < PE *** @ mclinn.com>在消息中写道

news:11 ********************** @ c13g2000cwb.googlegr oups.com ...
Some programmers refuse to use structs because they believe that you cannot
say that you will NEVER need a function. Therefore if they just make it a
class to start off with, this will never be a problem later on. Truthfully
I had this problem in C++ when I had to modify some code to change a couple
of struct to classes for this very reason. Therefore I like to go with the
idea of making everything a class.

"pmclinn" <pe***@mclinn.com> wrote in message
news:11**********************@c13g2000cwb.googlegr oups.com...
我注意到很多程序员使用类来存储有关这类内容的数据,例如:

类客户
....电话
。 ..ID
...地址

End Class ....

在VB.net中,''结构''对于存储更有意义这种类型的数据,如果你不打算使用函数/程序等等吗?
这只是旧的做事方式的拐杖还是有一个很好的理由做这个?

-Peter
I''ve noticed that many programmers use classes to store data about such
things like:

Class Customers
....Phone
...ID
...Address

End Class....

In VB.net, does a ''structure'' make more sense for storing this type of
data, if your not going to be using functions/Proceedures and such?
Is this just a crutch of the old way of doing things or is there a good
reason to do this?

-Peter



这篇关于结构与类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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