---
title: "Convert.ChangeType How to convert from String to Enum"  
description: "Convert.ChangeType How to convert from String to Enum"  
author: "Anonymous User"  
published: 2014-01-25  
updated: 2014-01-25  
canonical: https://www.mindstick.com/forum/1876/convert-changetype-how-to-convert-from-string-to-enum  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Convert.ChangeType How to convert from String to Enum

[Convert](https://www.mindstick.com/forum/2093/configurationmanager-appsettings-convert-n-to-n-why).ChangeType How to convert from [String to Enum](https://www.mindstick.com/forum/160708/convert-string-to-enum-in-c-sharp)

```
public static T Convert<T>(String value)  {    return
(T)Convert.ChangeType(value, typeof(T));  }   public enum
Category    {       Empty,       Name,       City,       Country   }  Category
cat=Convert<Category>("1");//Name=1
```

When I call Convert.ChangeType, the [system](https://www.mindstick.com/articles/23411/the-most-effective-method-to-find-the-perfect-small-business-phone-system-for-your-business) throws an [exception](https://www.mindstick.com/articles/1824/objective-c-exception-handling) on the impossibility of [conversion](https://www.mindstick.com/forum/1734/conversion-from-32-bit-integer-to-4-chars) from String to Category. How to do the conversion? Maybe I need to implement any converter for my type?

## Replies

### Reply by Pravesh Singh

Hi Ben,\

Use [Enum](https://www.mindstick.com/forum/159626/how-can-i-cast-a-string-to-an-enum).Parse method for this.

```
public static T Convert<T>(String value){    if(typeof(T).IsEnum)       return(T)Enum.Parse(typeof(T), value);    return(T)Convert.ChangeType(value, typeof(T));}
```


---

Original Source: https://www.mindstick.com/forum/1876/convert-changetype-how-to-convert-from-string-to-enum

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
