Be the first to rate this post
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5
May 18, 2007 9:23 AM
System.Collections.Generics.List is one of my favorite collection classes. While I wish they would have made some of the functions virtual, the creators did add several methods that take a delegate and invoke the delegate to either find items or process some action on the items in the collection. class Class1
{
private int _Value = 0;
public Class1(int value)
{ _Value = value; }
public static bool FindMyRange(Class1 i) { return i._Value > 5 && i._Value < 8; }
public static void MakeMostMyRange(Class1 i) {
if (i._Value == 9) i._Value = 8;
else if (i._Value - 4 > 0) i._Value = 6;
}
public static Predicate<Class1> Predicate_FindMyRange {
get { return new delegate(Class1 c) { return i._Value > 5 && i._Value < 8; }; } } [STAThread] static void Main(string[] args) {
List<Class1> list = new List<Class1>();
for(int i = 0; i < 10; i++) {
list.Add(new Class1(i)); }
Predicate<Class1> pred = new Predicate<Class1>(Class1.FindMyRange);
List<Class1> found = list.Find(pred);
bool trueForAll = list.TrueForAll(pred); // false
list.ForEach(new Action<Class1>(Class1.MakeMostMyRange));
trueForAll = list.TrueForAll(pred); // true
List<Class1> findMore = list.Find(Class1.Predicate_FindMyRange);
}} I personally prefer declaring the static property that returns the anonymous delegate because it really makes the code more straight forward.
Be the first to rate this post
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5
May 2, 2007 9:15 AM
I was unaware of a way to change my domain password through remote desktop (connected to another domain.)
I went off searching for the easiest solution and found the following:
net user [username] * /domain
This will prompt you to change your domain password, however, you must be an administrator!