"convert.changetype how to convert from string to enum" Code Answer

2

use 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));
}
By Yangguang on July 5 2022

Answers related to “convert.changetype how to convert from string to enum”

Only authorized users can answer the Search term. Please sign in first, or register a free account.