Re: Arrays as parameters

Peter Ritchie <[email protected]> Sat, 21 Jun 2008 21:17:28 -0400
Newsgroups gmane.comp.windows.devel.dotnet.winforms
Message-ID <LISTSERV%[email protected]>
Hi Steve, you could do this:

 private String[] strings = new String[10];
 public String[] Array
 {
  get
  {
   return strings;
  }
  set
  {
   strings = value;
  }
 }

But, this would allow:

sc.Array = new String[666];

as well as:
sc.Array[0] = "Zero";

If you don't want external client code to modify the Someclass.strings
member, simply don't offer a getter on the Array property.

Cheers -- Peter