Is there a way to pass class 'members' as first-class values?
public class Bike {
public Color BikeColour { get; set; }
public bool IsGirlsBike { get; set; }
}
I would like to then refer to the field names, without any notion of an object.
I guess what I want is something like an enum:
public enum BikeFields {BikeColour, IsGirlsBike};
but without defining it explicitly.
Is there a way to do this in C#?
Edit: Apologies for being so vague; I want to be able to refer to class members as first class things (almost like a bound type).
Set<Bike:T> whichFieldsHaveBeenDrawn = new Set<Bike:T>();
Bike:T is undefined, I hope the illustration below makes it clear how this new type will work.
whichFieldsHaveBeenDrawn.Include(Bike.BikeColour);
var remainingFields = Set.Subtract(Bike.GetAllFields(), whichFieldsHaveBeenDrawn);
Bike b = new Bike();
foreach (var field in remainingFields) { Draw(field, b); }
I think I can do this with reflection, but I want them qualified at compile time...