Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string[] colors = Enum.GetNames(typeof(System.Drawing.KnownColor));
- Type colorType = typeof(System.Drawing.Color);
- PropertyInfo[] propInfoList = colorType.GetProperties(BindingFlags.Static | BindingFlags.DeclaredOnly | BindingFlags.Public);
- foreach (System.Reflection.PropertyInfo c in propInfoList) {
- Console.WriteLine(c.Name);
- }
- foreach (KnownColor knownColor in Enum.GetValues(typeof(KnownColor)))
- {
- Trace.WriteLine(string.Format("{0}", knownColor));
- }
- System.Collections.Generic.List<string> colors =
- new System.Collections.Generic.List<string>();
- Type t = typeof(System.Drawing.Color);
- System.Reflection.PropertyInfo[] infos = t.GetProperties();
- foreach (System.Reflection.PropertyInfo info in infos)
- if (info.PropertyType == typeof(System.Drawing.Color))
- colors.Add(info.Name);
- using System.Collections.Generic;
- using System.Drawing;
- using System.Linq;
- ...
- static IEnumerable<Color> GetSystemColors() {
- Type type = typeof(Color);
- return type.GetProperties().Where(info => info.PropertyType == type).Select(info => (Color)info.GetValue(null, null));
- }
Add Comment
Please, Sign In to add comment