Click here to Skip to main content
15,901,426 members
Home / Discussions / C#
   

C#

 
GeneralRe: Undo() Method? Pin
Stefan Troschuetz11-Feb-07 20:39
Stefan Troschuetz11-Feb-07 20:39 
AnswerRe: Undo() Method? Pin
Stefan Troschuetz11-Feb-07 7:50
Stefan Troschuetz11-Feb-07 7:50 
AnswerRe: Undo() Method? Pin
ShermansLagoon11-Feb-07 19:50
ShermansLagoon11-Feb-07 19:50 
QuestionOpacity Pin
Fco. Javier Marin11-Feb-07 4:46
Fco. Javier Marin11-Feb-07 4:46 
QuestionArrayList with restricted access Pin
Mark T.11-Feb-07 4:11
Mark T.11-Feb-07 4:11 
AnswerRe: ArrayList with restricted access Pin
Stefan Troschuetz11-Feb-07 4:30
Stefan Troschuetz11-Feb-07 4:30 
AnswerRe: ArrayList with restricted access Pin
Luc Pattyn11-Feb-07 5:43
sitebuilderLuc Pattyn11-Feb-07 5:43 
GeneralRe: ArrayList with restricted access Pin
Mark T.11-Feb-07 10:51
Mark T.11-Feb-07 10:51 
Thanks to you both who responded.
I couldn't figure it out without you.

For others interested, here is a minimal solution class which seems to work so far. You may want to add other properties or functions, but this is what I need for now.

I call it a Firm List since, for the user only, the array size is no longer variable but is firm (solidified). The user can read and use each item in the list, but can't make the list contain a different item nor change the number of items in the list.
using System;
using System.Collections;

namespace FreeForAll {
  public class FirmList : IEnumerable {
    ArrayList foundation;

    public FirmList(ArrayList source) {
      foundation = source;
    }

    public IEnumerator GetEnumerator() {
      return foundation.GetEnumerator();
    }

    public bool Contains(object item) {
      return foundation.Contains(item);
    } 

    public int Count {
      get { return foundation.Count; }
    }
  }
}

Here is how, within another class, I return a FirmList as property "SomeList". Within this class, I have full accees to the ArrayList itself and all of its abilities.
class A {
  ArrayList TheRealList = new ArrayList();
  FirmList TheFirmList;
  A() {  // constructor
    TheFirmList = new FirmList(TheRealList);
  }
  ...
  void SomeFunctionThatAddsMembersToTheArrayList() {...};
  ...
  public FirmList SomeList {
    get { return TheFirmList; }
  }
}

And, finally, here is how some other code might use it, just like and ArrayList is used:
A aaa = new A();
aaa.SomeFunctionThatAddsMembersToTheArrayList();
FirmList list = A.SomeList;
foreach (object o in list) {
  ...
}
WriteLine("{0}", list.Count);
if (list.Contains(...)) {...



Hope this helps someone else.

Mark
AnswerRe: ArrayList with restricted access Pin
Syed Muhammad Kamran12-Feb-07 2:02
Syed Muhammad Kamran12-Feb-07 2:02 
QuestionDisabling Windows Buttons: Minimize,Restore,Close Pin
Blekk11-Feb-07 4:06
Blekk11-Feb-07 4:06 
AnswerRe: Disabling Windows Buttons: Minimize,Restore,Close Pin
Stefan Troschuetz11-Feb-07 4:24
Stefan Troschuetz11-Feb-07 4:24 
AnswerRe: Disabling Windows Buttons: Minimize,Restore,Close [modified] Pin
sharpiesharpie11-Feb-07 4:29
sharpiesharpie11-Feb-07 4:29 
GeneralRe: Disabling Windows Buttons: Minimize,Restore,Close Pin
Blekk11-Feb-07 6:14
Blekk11-Feb-07 6:14 
GeneralRe: Disabling Windows Buttons: Minimize,Restore,Close Pin
Blekk11-Feb-07 6:24
Blekk11-Feb-07 6:24 
GeneralRe: Disabling Windows Buttons: Minimize,Restore,Close Pin
sharpiesharpie11-Feb-07 6:56
sharpiesharpie11-Feb-07 6:56 
QuestionDisplaying a message when closing Pin
Blekk11-Feb-07 3:22
Blekk11-Feb-07 3:22 
AnswerRe: Displaying a message when closing Pin
cellardoor071611-Feb-07 3:46
cellardoor071611-Feb-07 3:46 
GeneralRe: Displaying a message when closing Pin
Blekk11-Feb-07 3:56
Blekk11-Feb-07 3:56 
QuestionIsNumeric Pin
IgorMI511-Feb-07 3:21
IgorMI511-Feb-07 3:21 
AnswerRe: IsNumeric Pin
Stefan Troschuetz11-Feb-07 4:35
Stefan Troschuetz11-Feb-07 4:35 
AnswerRe: IsNumeric Pin
ali_reza_zareian11-Feb-07 10:12
ali_reza_zareian11-Feb-07 10:12 
AnswerRe: IsNumeric Pin
Tim Paaschen11-Feb-07 20:47
Tim Paaschen11-Feb-07 20:47 
QuestionHow to change ms access column name in c# Pin
Neuromancer_11-Feb-07 3:19
Neuromancer_11-Feb-07 3:19 
QuestionIdentifying file type Pin
dream catcher11-Feb-07 1:26
dream catcher11-Feb-07 1:26 
AnswerRe: Identifying file type Pin
sharpiesharpie11-Feb-07 4:50
sharpiesharpie11-Feb-07 4:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.