ToEnum
using System; using System.Diagnostics; internal static class StringExtensions { public static T ToEnum<T>(this string value) where T : struct { Debug.Assert(!string.IsNullOrEmpty(value)); return (T)Enum.Parse(typeof(T), value, true); } }Example:
todo
Description
Parse a string value to the given Enum
Details
- Author: unkown
- Submitted on: 12/8/2007 8:24:53 PM
- Language: C#
- Type: System.String
- Views: 3643
Double click on the code to select all.