My favorites | Sign in
Project Logo
       
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ManagedFusion
{
public static class Utility
{
/// <summary>
/// Parses the specified value.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="value">The value.</param>
/// <returns></returns>
public static T ParseEnum<T>(string value)
{
if (!typeof(T).IsEnum)
throw new ArgumentException(typeof(T) + " is not an Enum");

try
{
return (T)Enum.Parse(typeof(T), value, true);
}
catch (Exception)
{
return default(T);
}
}
}
}
Show details Hide details

Change log

r30 by nberardi on Aug 28, 2009   Diff
refresh of ManagedFusion
Go to: 

Older revisions

All revisions of this file

File info

Size: 626 bytes, 31 lines
Hosted by Google Code