Phil,
I wouldn't say it is more correct or less correct to instantiate the
array list in the constructor or the declaration. They will result in the
same thing, the same semantics (for the most part).
Yes, the List property will return the reference to the ArrayList.
Just curious? If your lists are holdling an object of just one type,
then why not expose a List<Tor IList<T(and use a List<Tin the
_Internal field)? You would get much more type-safety that way.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"Phil Da Lick!" <ph***********@spammerskissmyarse.hotmail.comwro te in
message news:ev**************@TK2MSFTNGP06.phx.gbl...
Hi all,
Creating a class library with an object that needs to expose a list of
other objects. Using vs 2008/.NET 3.5.
So far got this:
public class MyClass
{
private ArrayList _Internal=new ArrayList();
public ArrayList List
{
get
{
return(_Internal);
}
}
public MyClass()
{
}
}
My questions:
1. Is it correct to create the _Internal object in its declaration as
shown, or should the call to new ArrayList() be in the constructor?
2. Am I right in assuming that calling MyClass.List will in effect return
a pointer to the list?
Cheers,
Phil.