I am trying to figure out a way to store the encoding of a file in a database, then get it back to its original type (System.Text.Encoding). But I get an error that I do not understand.
As a test, I created this small program to reproduce the error:
using System;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
object o = Encoding.Unicode;
Encoding enc = (Encoding) Enum.Parse(typeof(Encoding), o.ToString());
}
}
}
The exception that I get in the Parse line says:
Type provided must be an Enum.
Parameter name: enumType
So basically, as I understand it, they tell me that the typeof(Encoding)type is not Enum? Thanks in advance for the help provided.
source
share