Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jcapellman/jcehl
A PCL for C# programmers with extra handy helper methods
https://github.com/jcapellman/jcehl
Last synced: about 5 hours ago
JSON representation
A PCL for C# programmers with extra handy helper methods
- Host: GitHub
- URL: https://github.com/jcapellman/jcehl
- Owner: jcapellman
- License: mit
- Created: 2015-08-30T15:29:24.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-01-12T01:36:05.000Z (almost 9 years ago)
- Last Synced: 2024-04-28T01:11:25.966Z (7 months ago)
- Language: C#
- Homepage:
- Size: 23.4 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jcEHL
A PCL for C# programmers with handy helper methodsYou might find youself in a situation where you have a base class and then extend it with a few more properties like so:
```c#
public class Person {
public string FirstName { get; set; }
public string LastName { get; set; }
}public class Employee : Person {
public int YearsEmployed { get; set; }
}
```Traditionally, you would have to in your Employee class's constructor initialize the FirstName and LastName properties. Which for this small of a class isn't a huge deal, but most classes have 5+ properties and can change. I often found myself wishing C# had the ability to simply say - initialize the members of the base class members and then allow me to just focus on the extended class's properties.
Now you can with one line of code in your base class's constructor, using the class above:
```C#
public class Person {
public string FirstName { get; set; }
public string LastName { get; set; }
public Person() { }
public Person(Person basePerson) { Copy.Init(basePerson, this); }
}public class Employee : Person {
public int YearsEmployed { get; set; }
public Employee() { }
public Employee(Person basePerson) : base(basePerson) { }
}
```