E
Eric
Will someone tell me if this is an efficient and appropriate way of storing
strongly typed class properties? I want a cleaner approach to "property per
flag" method and I want things strongly typed for design time if possible.
class Program
{
static void Main(string[] args)
{
MyClass myClass = new MyClass();
Console.WriteLine(myClass[MyClass.Property.Property1]);
Console.WriteLine(myClass[MyClass.Property.Property2]);
Console.WriteLine(myClass[MyClass.Property.Property3]);
Console.ReadLine();
}
}
public class MyClass
{
public enum Property
{
Property1,
Property2,
Property3
}
private Dictionary<Property, bool> _propertyData = new
Dictionary<Property,bool>();
public MyClass()
{
_propertyData[Property.Property1] = true;
_propertyData[Property.Property2] = false;
_propertyData[Property.Property3] = true;
}
public bool this[Property p]
{
get { return _propertyData[p]; }
}
}
Thank You
Eric Brasher
strongly typed class properties? I want a cleaner approach to "property per
flag" method and I want things strongly typed for design time if possible.
class Program
{
static void Main(string[] args)
{
MyClass myClass = new MyClass();
Console.WriteLine(myClass[MyClass.Property.Property1]);
Console.WriteLine(myClass[MyClass.Property.Property2]);
Console.WriteLine(myClass[MyClass.Property.Property3]);
Console.ReadLine();
}
}
public class MyClass
{
public enum Property
{
Property1,
Property2,
Property3
}
private Dictionary<Property, bool> _propertyData = new
Dictionary<Property,bool>();
public MyClass()
{
_propertyData[Property.Property1] = true;
_propertyData[Property.Property2] = false;
_propertyData[Property.Property3] = true;
}
public bool this[Property p]
{
get { return _propertyData[p]; }
}
}
Thank You
Eric Brasher