Initializing Array as Object Property

I'm having problems with a null reference in VB.NET and haven't been able to find the proper way to initialize the array of objects that are a property of another object.  In C#, you can successfully do the following:

request.Items = new BTUnit[] { unit1, unit2 };

However, I don't know how to do this in VB.  I cannot set the individual values of the array as follows because the array hasn't been initialized:

request.items(0) = unit1
request.items(1) = unit2

Calling request.items.initialize results in a null references.  I also can't use request.items.createinstance because "BTUnit" is not a system.type.

Any ideas?
CUOL-MISAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

lazyberezovskyCommented:
Code below should work
request.Items = New BTUnit() {unit1, unit2}

Open in new window

0
CUOL-MISAuthor Commented:
Yes, I thought the same thing.  I tried that syntax previously but the issue is with the class itself.  In the VB app, the class is a partial class that is defined with MustInherit.  In the C# app, the partial class is defined as Abstract.  For some reason, the abstract class in C# inherits the Object class but the mustinherit class doesn't inherit Object in VB.  The class is from a web reference, so I don't know why VS 2005 would treat it differently based on the language.
0
lazyberezovskyCommented:
Any class in .Net (not matter C# or VB.NET) is inherited from System.Object.
See: http://msdn.microsoft.com/en-us/library/0zw9e48h(VS.71).aspx

So, you can be sure there is other reason.
Maybe your request object is set to null?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.