As I stated, I rarely do:
| > | dim objtest3 as car = new car
I favor:
| > | dim objtest2 as new car
Which you use doesn't matter IMHO, as long as you consistently use one.
I will use:
| > | dim objtest3 as car = car.Factory()
Where Car.Factory is a method that creates (or possibly looks up a cached
car) for me.
| Is this just preference or was their a reason?
Having a mix of:
| > | dim objtest2 as new car
| > | dim objtest3 as car = new car
Feels like an odd-ball solution. At the very least it feels very
inconsistent.
--
Hope this helps
Jay B. Harlow [MVP - Outlook]
.NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley -
http://www.tsbradley.net
| Yes. It did.
|
| One final question about
| > | dim objtest2 as new car
| > | dim objtest3 as car = new car
| > Defines variables that can hold Car objects, initializes those
variables
| > with new Car objects.
|
| Why not always use dim objtest2 as new car? The second requires more
| typing, etc. Is there any reason why not always to use the first
statement.
| The reason I ask is because in some code by same author in same assembly
I
| find the use of both. Is this just preference or was their a reason?
|
| Thanks again.
|
|
| message | > RdS,
| > | Would someone tell me the differences between following statements?
| > | dim objtest1 as car
| > Assuming Car is a reference type. Defines a variable that can hold a
Car
| > object, however no Car object is created.
| >
| > | dim objtest2 as new car
| > | dim objtest3 as car = new car
| > Defines variables that can hold Car objects, initializes those
variables
| > with new Car objects.
| >
| >
| > | When would you use one over the other?
| > | dim objtest1 as car
| > | dim objtest2 as new car
| > I would use the first when the Car object was coming from someplace
else
| > (such as the control variable in a For Each, or the return value from
a
| > function).
| >
| >
| > | Are not objtest2 and objtest3 doing the same thing? I understand
the
=
| > | after variable declaration sets initial value but would like
| > clarification.
| > Yes they are the same thing,
| >
| > | dim objtest3 as car = new car
| > I use it when I may create a derived class, but be certain that I'm
only
| > using base class methods.
| >
| > Dim s As Stream = New FileStream(...)
| >
| > However generally the New FileStream is actually hidden in a factory
| > method
| > someplace...
| >
| > --
| > Hope this helps
| > Jay B. Harlow [MVP - Outlook]
| > .NET Application Architect, Enthusiast, & Evangelist
| > T.S. Bradley -
http://www.tsbradley.net
| >
| >
| > | > | Hello
| > |
| > | Would someone tell me the differences between following statements?
| > When
| > | would you use one over the other?
| > |
| > | dim objtest1 as car
| > | dim objtest2 as new car
| > | dim objtest3 as car = new car
| > |
| > | Are not objtest2 and objtest3 doing the same thing? I understand
the
=
| > | after variable declaration sets initial value but would like
| > clarification.
| > |

| > |
| > | thanks.
| > |
| > |
| >
| >
|
|