Returning four values from a function...
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngvb' list.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.

Greg Quinn
Is there any way to return four different values from a function?

Greg

Reply to this message...
 
    
Eric Landes (VIP)
Greg,
Utilizing VB.net there are a number of ways to do this. One way I'm =
using
would be to create a colleciton in your class and populate that =
collection
with your data. This assumes that those values are related in some way =
(for
instance in order detail lines would be in the orderdetail collection of =
the
Orders class). Some sample code:
Public Class Myclass
    Public childCollection As New Collection()

    Public Sub GetRecords()
... Code to get your data
    childCollection.Add(childObject, childObject.ID)

    End Sub
end class

Not sure if that's what you are looking for. Another way to do it is by
utilizing properties in your class, and having your function populate =
the
properties. Then your calling program could use those properties.

I'm not sure that these are the most scalable methods, but I am finding =
them
very maintainable. But again, my sites are intranets that don't have
millions of hits or activity, so keep that in mind.

*************************=20
Eric Landes=20
Senior Programmer/Analyst=20
For Articles on Crystal.Net, Datagrids and more check out
http://www.aspalliance.com/corporatecoder/
*************************=20
All statements expressed are my own, and do not reflect the opinion of =
my
employer, unless stated otherwise.=20

-----Original Message-----
From: Greg Quinn [mailto:Click here to reveal e-mail address]
Sent: Monday, July 29, 2002 3:53 PM
To: aspngvb
Subject: [aspngvb] Returning four values from a function...

Is there any way to return four different values from a function?

Greg

Confidentiality Notice: This e-mail message, including any
attachments, is for the sole use of the intended recipient(s) and may
contain confidential and privileged information. Any unauthorized
review, use, disclosure or distribution is prohibited. If you are not
the intended recipient, please contact the sender by reply e-mail and
destroy all copies of the original message.

PARTNERS Health Plan Phone: 574-233-4899
100 E. Wayne St., Suite 502 Fax: 574-234-7484
South Bend, IN 46601 www.partnersindiana.com

Reply to this message...
 
    
Guillermo E. Rivero
Do you want to return the 4 values at the same time ?

If so, you can return a structure with the 4 values...

If not, you can return an object then cast it to the type you want...

Reply to this message...
 
    
Tim Maloney
One way would be to use a structure

structure stMyData
Dim strProduct as String
Dim dblPrice as Double
Dim lngStock as Long
End Structure

Sub Go()

Dim stGet as stMyData

stGet = GetData
'Your values from GetData should have been returned
Response.Write(stGet.strProduct)

End Sub

Function GetData() as stMyData

Dim stTest as stMyData

stTest.strProduct = "Widgets"
stTest.dblPrice = "2.54"
stTest.lngStock = "25"

GetData = stTest

End Function

If these values are of the same type (meaning it is not a 'record' of
sorts) then I believe with the new version you can return arrays. (You may
even be able to define an array in a structure but I haven't had need for
this as of yet...

Tim Maloney
Alliance Consulting

[Original message clipped]

Reply to this message...
 
    
joseph.gaus@dowcorning.com
Another way would be to define a struct with fields, have your function
create an instance of that struct, populate those fields, and pass the
struct back as it's return type.

-----Original Message-----
From: Eric Landes [mailto:Click here to reveal e-mail address]
Sent: Monday, July 29, 2002 9:58 AM
To: aspngvb
Subject: [aspngvb] RE: Returning four values from a function...

Greg,
Utilizing VB.net there are a number of ways to do this. One way I'm using
would be to create a colleciton in your class and populate that collection
with your data. This assumes that those values are related in some way (for
instance in order detail lines would be in the orderdetail collection of the
Orders class). Some sample code:
Public Class Myclass
    Public childCollection As New Collection()

    Public Sub GetRecords()
... Code to get your data
    childCollection.Add(childObject, childObject.ID)

    End Sub
end class

Not sure if that's what you are looking for. Another way to do it is by
utilizing properties in your class, and having your function populate the
properties. Then your calling program could use those properties.

I'm not sure that these are the most scalable methods, but I am finding them
very maintainable. But again, my sites are intranets that don't have
millions of hits or activity, so keep that in mind.

*************************
Eric Landes
Senior Programmer/Analyst
For Articles on Crystal.Net, Datagrids and more check out
http://www.aspalliance.com/corporatecoder/
*************************
All statements expressed are my own, and do not reflect the opinion of my
employer, unless stated otherwise.

-----Original Message-----
From: Greg Quinn [mailto:Click here to reveal e-mail address]
Sent: Monday, July 29, 2002 3:53 PM
To: aspngvb
Subject: [aspngvb] Returning four values from a function...

Is there any way to return four different values from a function?

Greg

Confidentiality Notice: This e-mail message, including any
attachments, is for the sole use of the intended recipient(s) and may
contain confidential and privileged information. Any unauthorized
review, use, disclosure or distribution is prohibited. If you are not
the intended recipient, please contact the sender by reply e-mail and
destroy all copies of the original message.

PARTNERS Health Plan Phone: 574-233-4899
100 E. Wayne St., Suite 502 Fax: 574-234-7484
South Bend, IN 46601 www.partnersindiana.com

| [aspngvb] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngvb.asp = JOIN/QUIT

________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs SkyScan
service. For more information on a proactive anti-virus service working
around the clock, around the globe, visit http://www.messagelabs.com
________________________________________________________________________

________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs SkyScan
service. For more information on a proactive anti-virus service working
around the clock, around the globe, visit http://www.messagelabs.com
________________________________________________________________________

Reply to this message...
 
    
leon jollans
Hi Greg,=20
would have thought you have two choices, either use ByRef/ref parameters =
or return an array from the function. Don't think there's any other way, =
if there is I'd love to know about it.

hth
Leon

-----Original Message-----
From: Greg Quinn [mailto:Click here to reveal e-mail address]
Sent: 29 July 2002 21:53
To: aspngvb
Subject: [aspngvb] Returning four values from a function...

Is there any way to return four different values from a function?

Greg

| [aspngvb] member Click here to reveal e-mail address =3D YOUR ID
| http://www.asplists.com/asplists/aspngvb.asp =3D JOIN/QUIT

Reply to this message...
 
    
Remas Wojciechowski
Greg,

probably the best way is to define a custom class with 4 properties and have
the function return objects of that type.

hth
Remas
http://www.aspalliance.com/remas

----- Original Message -----
From: "Greg Quinn" <Click here to reveal e-mail address>
To: "aspngvb" <Click here to reveal e-mail address>
Sent: Monday, July 29, 2002 10:52 PM
Subject: [aspngvb] Returning four values from a function...

[Original message clipped]

Reply to this message...
 
    
Greg Quinn
So then how do I call these values from my .aspx page?

i.e myValue1 = GetRecords.childCollection(1) ???

Greg

-----Original Message-----
From: Eric Landes [mailto:Click here to reveal e-mail address]
Sent: 29 July 2002 06:58
To: aspngvb
Subject: [aspngvb] RE: Returning four values from a function...

Greg,
Utilizing VB.net there are a number of ways to do this. One way I'm using
would be to create a colleciton in your class and populate that collection
with your data. This assumes that those values are related in some way (for
instance in order detail lines would be in the orderdetail collection of the
Orders class). Some sample code:
Public Class Myclass
    Public childCollection As New Collection()

    Public Sub GetRecords()
... Code to get your data
    childCollection.Add(childObject, childObject.ID)

    End Sub
end class

Not sure if that's what you are looking for. Another way to do it is by
utilizing properties in your class, and having your function populate the
properties. Then your calling program could use those properties.

I'm not sure that these are the most scalable methods, but I am finding them
very maintainable. But again, my sites are intranets that don't have
millions of hits or activity, so keep that in mind.

*************************
Eric Landes
Senior Programmer/Analyst
For Articles on Crystal.Net, Datagrids and more check out
http://www.aspalliance.com/corporatecoder/
*************************
All statements expressed are my own, and do not reflect the opinion of my
employer, unless stated otherwise.

-----Original Message-----
From: Greg Quinn [mailto:Click here to reveal e-mail address]
Sent: Monday, July 29, 2002 3:53 PM
To: aspngvb
Subject: [aspngvb] Returning four values from a function...

Is there any way to return four different values from a function?

Greg

Confidentiality Notice: This e-mail message, including any
attachments, is for the sole use of the intended recipient(s) and may
contain confidential and privileged information. Any unauthorized
review, use, disclosure or distribution is prohibited. If you are not
the intended recipient, please contact the sender by reply e-mail and
destroy all copies of the original message.

PARTNERS Health Plan Phone: 574-233-4899
100 E. Wayne St., Suite 502 Fax: 574-234-7484
South Bend, IN 46601 www.partnersindiana.com

| [aspngvb] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngvb.asp = JOIN/QUIT

Reply to this message...
 
    
eric landes (VIP)
Greg,
Something like this:
dim myObj as new EricsObject
dim myTestString as string

myObj.GetRecords
myTeststring =3D myobj.Childcollection(1)

myobj=3Dnothing

Or if you put a struct in there (as others have mentioned), do same type =
of code, but call the variable name. HTH
Eric

----- Original Message -----
From: "Greg Quinn" <Click here to reveal e-mail address>
To: Click here to reveal e-mail address
Sent: Mon, 29 Jul 2002 16:19:39 -0700
Subject: RE: [aspngvb] RE: Returning four values from a function...
[Original message clipped]

Sent: 29 July 2002 06:58
To: aspngvb
Subject: [aspngvb] RE: Returning four values from a function...
[Original message clipped]

Sent: Monday, July 29, 2002 3:53 PM
To: aspngvb
Subject: [aspngvb] Returning four values from a function...
[Original message clipped]

Reply to this message...
 
    
Darren Neimke
WW91IGNvdWxkIHBhc3MgYmFjayBhIFN0cnVjdHVyZSBvciBDbGFzcywgb3IgeW91IGNvdWxkIHBh
c3MgdGhlIHZhbHVlcyBCeVJlZi4NCg0KCS0tLS0tT3JpZ2luYWwgTWVzc2FnZS0tLS0tIA0KCUZy
b206IEdyZWcgUXVpbm4gW21haWx0bzpncmVnQGktb25saW5lLmNvLnphXSANCglTZW50OiBUdWUg
MzAvMDcvMjAwMiA2OjIyIEFNIA0KCVRvOiBhc3BuZ3ZiIA0KCUNjOiANCglTdWJqZWN0OiBbYXNw
bmd2Yl0gUmV0dXJuaW5nIGZvdXIgdmFsdWVzIGZyb20gYSBmdW5jdGlvbi4uLg0KCQ0KCQ0KDQoJ
SXMgdGhlcmUgYW55IHdheSB0byByZXR1cm4gZm91ciBkaWZmZXJlbnQgdmFsdWVzIGZyb20gYSBm
dW5jdGlvbj8NCgkNCglHcmVnDQoJDQoJDQoJfCBbYXNwbmd2Yl0gbWVtYmVyIGRhcnJlbi5uZWlt
a2VAc2RtLmNvbS5hdSA9IFlPVVIgSUQNCgl8IGh0dHA6Ly93d3cuYXNwbGlzdHMuY29tL2FzcGxp
c3RzL2FzcG5ndmIuYXNwID0gSk9JTi9RVUlUDQoJDQoNCg=
Reply to this message...
 
    
Peter Brunone
Greg,

How about returning an array (or other multi-value datatype)?

Cheers,

Peter

----- Original Message -----
From: "Greg Quinn" <Click here to reveal e-mail address>

[Original message clipped]

Reply to this message...
 
    
Peter Brunone
Tim,

Nice approach; I guess I've learned my new thing for today :)

Anybody know how expensive structures are?

Cheers,

Peter

----- Original Message -----
From: "Tim Maloney" <Click here to reveal e-mail address>

[Original message clipped]

Reply to this message...
 
    
Alex Lowe
The structure is less expensive than say a class but provides much of
the same functionality. The reason the structure is less expensive is
that it is a value type rather than a reference type.

What does this mean (value vs. reference)? Well, reference types are
stored in a unique location on the managed heap (this means that the
only way they are deallocated is by the garbage collector). Value types
are types are stored where ever they are used (the exception being
something like an array of value types - the array is stored on the
managed heap - this is still different than a true reference type
however because when you request a value in the array you get a copy of
the value rather than a reference to the location of the value).

There are other difference between the structure (value type) and say a
class (reference type) that have to do with constructors,
initialization, lack of inheritance, etc. So, there is a tradeoff
between speed/performance and encapsulation. Generally speaking though,
if all you care about is a value (or values) and you are not concerned
with maintaining a unique instance of a class then a structure will do.

Hth,

Alex - AspFriends.com Moderation Team
Microsoft MVP - ASP.NET

***********************************************************
Translate C# code to VB.NET code at
http://aspalliance.com/aldotnet/examples/translate.aspx
***********************************************************

[Original message clipped]

Reply to this message...
 
    
Iain Smallwood
My understanding is also:

A) If your structure contains reference objects e.g. a string, it is
better to just use a string - structures are best for sets of
co-ordinates etc
B) MS guidelines say the overhead of copying data in value types exceeds
the overhead of garbage collection once you get past 16 bytes

From my point of view they are now a lot less desirable than in VB6. Any
comments?

Cheers,
Iain

-----Original Message-----
From: Alex Lowe [mailto:Click here to reveal e-mail address]
Sent: 29 July 2002 15:53
To: aspngvb
Subject: [aspngvb] Re: Returning four values from a function...

The structure is less expensive than say a class but provides much of
the same functionality. The reason the structure is less expensive is
that it is a value type rather than a reference type.

What does this mean (value vs. reference)? Well, reference types are
stored in a unique location on the managed heap (this means that the
only way they are deallocated is by the garbage collector). Value types
are types are stored where ever they are used (the exception being
something like an array of value types - the array is stored on the
managed heap - this is still different than a true reference type
however because when you request a value in the array you get a copy of
the value rather than a reference to the location of the value).

There are other difference between the structure (value type) and say a
class (reference type) that have to do with constructors,
initialization, lack of inheritance, etc. So, there is a tradeoff
between speed/performance and encapsulation. Generally speaking though,
if all you care about is a value (or values) and you are not concerned
with maintaining a unique instance of a class then a structure will do.

Hth,

Alex - AspFriends.com Moderation Team
Microsoft MVP - ASP.NET

***********************************************************
Translate C# code to VB.NET code at
http://aspalliance.com/aldotnet/examples/translate.aspx
***********************************************************

[Original message clipped]

| [aspngvb] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngvb.asp = JOIN/QUIT

Disclaimer
This message may contain information which is legally privileged and/or
confidential. If you are not the intended recipient, you are hereby
notified that any unauthorised disclosure, copying, distribution or use
of this information is strictly prohibited. Such notification not
withstanding, any comments or opinions expressed are those of the
originator, not of Taylor Made Computer Solutions, unless otherwise
explicitly stated.

Reply to this message...
 
    
joseph.gaus@dowcorning.com
You're points are well made, from a performance point of view.

While performance is still important, and still should be kept in mind,
Microsoft has something else in mind with .NET. Best practices are no
longer based on performance (though it is kept in mind), best practices with
.NET include reducing programming time, both up front and from a
break/fix/maintenance point of view.

When looking for a solution to returning 4 values from a class, we should
ask what is the most understandable, scalable (scalable in terms of
upgrading code, inheriting, expanding use of code), and yes, easiest (as
well as taking into account performance).

While, as you argue, structures may not be the absolute fastest/best
performing solution, they do tend to fit some of the other design goals of
.NET in this case. I should say, I don't mean to say, you're wrong - I'm
just adding to your comments, touching on the other goals of .NET.

I do have a specific question about your comments. You theorize that
structures are now a lot less desirable. Are they handled worse in .NET?
Or did everything else get better (so they are worse by comparison)? Just
curious. Your comment about copying value types v. garbage collection is
interesting, do you have a source or know where more information is about
that? I'd love to read more on the topic - it looks like it would have a
good discussion on how a lot of things work under the hood.

Thanks,
Joe

-----Original Message-----
From: Iain Smallwood [mailto:Click here to reveal e-mail address]
Sent: Tuesday, July 30, 2002 4:39 AM
To: aspngvb
Subject: [aspngvb] Re: Returning four values from a function...

My understanding is also:

A) If your structure contains reference objects e.g. a string, it is
better to just use a string - structures are best for sets of
co-ordinates etc
B) MS guidelines say the overhead of copying data in value types exceeds
the overhead of garbage collection once you get past 16 bytes

From my point of view they are now a lot less desirable than in VB6. Any
comments?

Cheers,
Iain

-----Original Message-----
From: Alex Lowe [mailto:Click here to reveal e-mail address]
Sent: 29 July 2002 15:53
To: aspngvb
Subject: [aspngvb] Re: Returning four values from a function...

The structure is less expensive than say a class but provides much of
the same functionality. The reason the structure is less expensive is
that it is a value type rather than a reference type.

What does this mean (value vs. reference)? Well, reference types are
stored in a unique location on the managed heap (this means that the
only way they are deallocated is by the garbage collector). Value types
are types are stored where ever they are used (the exception being
something like an array of value types - the array is stored on the
managed heap - this is still different than a true reference type
however because when you request a value in the array you get a copy of
the value rather than a reference to the location of the value).

There are other difference between the structure (value type) and say a
class (reference type) that have to do with constructors,
initialization, lack of inheritance, etc. So, there is a tradeoff
between speed/performance and encapsulation. Generally speaking though,
if all you care about is a value (or values) and you are not concerned
with maintaining a unique instance of a class then a structure will do.

Hth,

Alex - AspFriends.com Moderation Team
Microsoft MVP - ASP.NET

***********************************************************
Translate C# code to VB.NET code at
http://aspalliance.com/aldotnet/examples/translate.aspx
***********************************************************

[Original message clipped]

| [aspngvb] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngvb.asp = JOIN/QUIT

Disclaimer
This message may contain information which is legally privileged and/or
confidential. If you are not the intended recipient, you are hereby
notified that any unauthorised disclosure, copying, distribution or use
of this information is strictly prohibited. Such notification not
withstanding, any comments or opinions expressed are those of the
originator, not of Taylor Made Computer Solutions, unless otherwise
explicitly stated.

| [aspngvb] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngvb.asp = JOIN/QUIT

________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs SkyScan
service. For more information on a proactive anti-virus service working
around the clock, around the globe, visit http://www.messagelabs.com
________________________________________________________________________

________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs SkyScan
service. For more information on a proactive anti-virus service working
around the clock, around the globe, visit http://www.messagelabs.com
________________________________________________________________________

Reply to this message...
 
    
Iain Smallwood
I totally agree maintenance, readability and structure are far more
important that a few split seconds performance any day of the year.
Experience has given me more respect for those than anything else!

In response to your question it is the way that structures are assigned.
The data in a value type is copied during any assignment as opposed to
pointed to or referred to. But they do not have to be GC'd as they are
on the stack. The benefit of the non GC thing is soon outgrown by the
assignment thing. Thus if a structure is at all liable to grow, or you
use reference types in it, you may as well go all the way and make a
class. It is just structures were lightweight-ish way of shuffling data
in VB6, function returns etc. Now this is not really the case. This is
my primitive understanding distilled from MSDN, Richter, Appleman and
about a thousand sources which I can barely understand (though I am
getting closer now!). Sorry to not be more specific.

What I would use structures for now is things like graphical transform
type stuff or similar multiple number manipulation tasks (assuming we
are not going APeI!). Anyone got any other good reasons to go structure,
or care to contradict a simple lad?

Cheers,
Iain

-----Original Message-----
From: Click here to reveal e-mail address [mailto:Click here to reveal e-mail address]
Sent: 30 July 2002 12:22
To: aspngvb
Subject: [aspngvb] Re: Returning four values from a function...

You're points are well made, from a performance point of view.

While performance is still important, and still should be kept in mind,
Microsoft has something else in mind with .NET. Best practices are no
longer based on performance (though it is kept in mind), best practices
with .NET include reducing programming time, both up front and from a
break/fix/maintenance point of view.

When looking for a solution to returning 4 values from a class, we
should ask what is the most understandable, scalable (scalable in terms
of upgrading code, inheriting, expanding use of code), and yes, easiest
(as well as taking into account performance).

While, as you argue, structures may not be the absolute fastest/best
performing solution, they do tend to fit some of the other design goals
of .NET in this case. I should say, I don't mean to say, you're wrong -
I'm just adding to your comments, touching on the other goals of .NET.

I do have a specific question about your comments. You theorize that
structures are now a lot less desirable. Are they handled worse in
.NET? Or did everything else get better (so they are worse by
comparison)? Just curious. Your comment about copying value types v.
garbage collection is interesting, do you have a source or know where
more information is about that? I'd love to read more on the topic - it
looks like it would have a good discussion on how a lot of things work
under the hood.

Thanks,
Joe

-----Original Message-----
From: Iain Smallwood [mailto:Click here to reveal e-mail address]
Sent: Tuesday, July 30, 2002 4:39 AM
To: aspngvb
Subject: [aspngvb] Re: Returning four values from a function...

My understanding is also:

A) If your structure contains reference objects e.g. a string, it is
better to just use a string - structures are best for sets of
co-ordinates etc
B) MS guidelines say the overhead of copying data in value types exceeds
the overhead of garbage collection once you get past 16 bytes

From my point of view they are now a lot less desirable than in VB6. Any
comments?

Cheers,
Iain

-----Original Message-----
From: Alex Lowe [mailto:Click here to reveal e-mail address]
Sent: 29 July 2002 15:53
To: aspngvb
Subject: [aspngvb] Re: Returning four values from a function...

The structure is less expensive than say a class but provides much of
the same functionality. The reason the structure is less expensive is
that it is a value type rather than a reference type.

What does this mean (value vs. reference)? Well, reference types are
stored in a unique location on the managed heap (this means that the
only way they are deallocated is by the garbage collector). Value types
are types are stored where ever they are used (the exception being
something like an array of value types - the array is stored on the
managed heap - this is still different than a true reference type
however because when you request a value in the array you get a copy of
the value rather than a reference to the location of the value).

There are other difference between the structure (value type) and say a
class (reference type) that have to do with constructors,
initialization, lack of inheritance, etc. So, there is a tradeoff
between speed/performance and encapsulation. Generally speaking though,
if all you care about is a value (or values) and you are not concerned
with maintaining a unique instance of a class then a structure will do.

Hth,

Alex - AspFriends.com Moderation Team
Microsoft MVP - ASP.NET

***********************************************************
Translate C# code to VB.NET code at
http://aspalliance.com/aldotnet/examples/translate.aspx
***********************************************************

[Original message clipped]

| [aspngvb] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngvb.asp = JOIN/QUIT

Disclaimer
This message may contain information which is legally privileged and/or
confidential. If you are not the intended recipient, you are hereby
notified that any unauthorised disclosure, copying, distribution or use
of this information is strictly prohibited. Such notification not
withstanding, any comments or opinions expressed are those of the
originator, not of Taylor Made Computer Solutions, unless otherwise
explicitly stated.

| [aspngvb] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngvb.asp = JOIN/QUIT

________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs SkyScan
service. For more information on a proactive anti-virus service working
around the clock, around the globe, visit http://www.messagelabs.com
________________________________________________________________________

________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs SkyScan
service. For more information on a proactive anti-virus service working
around the clock, around the globe, visit http://www.messagelabs.com
________________________________________________________________________

| [aspngvb] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngvb.asp = JOIN/QUIT

Disclaimer
This message may contain information which is legally privileged and/or
confidential. If you are not the intended recipient, you are hereby
notified that any unauthorised disclosure, copying, distribution or use
of this information is strictly prohibited. Such notification not
withstanding, any comments or opinions expressed are those of the
originator, not of Taylor Made Computer Solutions, unless otherwise
explicitly stated.

Reply to this message...
 
    
Alex Lowe
Iain and Joseph are right on and point out very valid points that I did
not mention - thanks.

One thing they did not touch on specicially (although Iain is onto it
with the copying issue) is that a major breakdown here is when
structures have to be boxed and unboxed. Read here for more information
and examples
(http://msdn.microsoft.com/library/en-us/dndotnet/html/dotnetperftechs.a
sp?frame=true#dotnetperftechs_topic8).

As for the guidelines (previously mentioned by Iain) with structures, go
here
(http://msdn.microsoft.com/library/en-us/cpgenref/html/cpconvaluetypeusa
geguidelines.asp).

Basically, if the type would be more efficiently passed by reference (as
in the case with large strings or other sizable values) then you will
want to take advantage of a reference type.

Another point for those of you migrating VB6 applications or doing some
interop is that there are virtually no performance penalties when
passing value types. So, you definitely don't want to pass around
(between the VB6 and .NET environment) classes that will contain mostly
primitive type values.

Alex - AspFriends.com Moderation Team
Microsoft MVP - ASP.NET

***********************************************************
Translate C# code to VB.NET code at
http://aspalliance.com/aldotnet/examples/translate.aspx
***********************************************************

[Original message clipped]

Reply to this message...
 
 




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com