You’d want to do more than just cycle through the keys in the core method of course, and I do but I’ve cut that bit out and just left the juicy bits.
I’m a big fan of wrapping.
public string GetFullNameForFoo() {
return GetFooData( new string [] {"firstName", "lastName"} );
}
public string GetUserNameForFoo() {
return GetFooData( new string [] {"userName"} );
}
private string GetFooData( string [] keys ) {
foreach ( string k in keys ){
retVal += r[ k ] + " ";
}
return retVal;
}