CodeRush Love...
I've recently acquired a CodeRush license for my personal use, and all I can say is ... I LOVE CODERUSH!You may be asking, "Why do you love CodeRush, Tim?" Here's why. By using the following sequence :
C Space P E R S O NClick to the end of constructor blockEnter P S Space F I R S T N A M EClick to the end of the property blockEnter P S Space L A S T N A M EClick on class nameCtrl-CClick outside of the classcoll Space
Produces all of the following code:
public class Person
{
public Person(string myFileName)
{
}
private string _FirstName;
public string FirstName
{
get
{
return _FirstName;
}
set
{
_FirstName = value;
}
}
private string _LastName;
public string LastName
{
get
{
return _LastName;
}
set
{
_LastName = value;
}
}
}
{
public Person(string myFileName)
{
}
private string _FirstName;
public string FirstName
{
get
{
return _FirstName;
}
set
{
_FirstName = value;
}
}
private string _LastName;
public string LastName
{
get
{
return _LastName;
}
set
{
_LastName = value;
}
}
}
public class PersonCollection : CollectionBase
{
// public methods...
#region Add
public int Add(Person person)
{
return List.Add(person);
}
#endregion
#region IndexOf
public int IndexOf(Person person)
{
for (int i = 0; i < List.Count; i++)
if (this[i] == person) // Found it
return i;
return -1;
}
#endregion
#region Insert
public void Insert(int index, Person person)
{
List.Insert(index, person);
}
#endregion
#region Remove
public void Remove(Person person)
{
List.Remove(person);
}
#endregion
#region Find
// TODO: If desired, change parameters to Find method to search based on a property of Person.
public Person Find(Person person)
{
foreach (Person lPersonItem in this)
if (lPersonItem == person) // Found it
return lPersonItem;
return null; // Not found
}
#endregion
#region Contains
// TODO: If you changed the parameters to Find (above), change them here as well.
public bool Contains(Person person)
{
return (Find(person) != null);
}
#endregion
// public properties...
#region this[int aIndex]
public Person this[int index]
{
get
{
return (Person)List[index];
}
set
{
List[index] = value;
}
}
#endregion
}
{
// public methods...
#region Add
public int Add(Person person)
{
return List.Add(person);
}
#endregion
#region IndexOf
public int IndexOf(Person person)
{
for (int i = 0; i < List.Count; i++)
if (this[i] == person) // Found it
return i;
return -1;
}
#endregion
#region Insert
public void Insert(int index, Person person)
{
List.Insert(index, person);
}
#endregion
#region Remove
public void Remove(Person person)
{
List.Remove(person);
}
#endregion
#region Find
// TODO: If desired, change parameters to Find method to search based on a property of Person.
public Person Find(Person person)
{
foreach (Person lPersonItem in this)
if (lPersonItem == person) // Found it
return lPersonItem;
return null; // Not found
}
#endregion
#region Contains
// TODO: If you changed the parameters to Find (above), change them here as well.
public bool Contains(Person person)
{
return (Find(person) != null);
}
#endregion
// public properties...
#region this[int aIndex]
public Person this[int index]
{
get
{
return (Person)List[index];
}
set
{
List[index] = value;
}
}
#endregion
}