Convert
object result = Convert.ChangeType(object 值, Type 目标类型);String转对应Enum
if (Enum.TryParse(Type 目标枚举类型, string 值, out object result)) {
// result...
}object result = Convert.ChangeType(object 值, Type 目标类型);if (Enum.TryParse(Type 目标枚举类型, string 值, out object result)) {
// result...
}作者: Chaim
链接: https://chaim.eu.org/posts/%E7%B1%BB%E5%9E%8B%E8%BD%AC%E6%8D%A2/
许可证: CC BY-NC-SA 4.0
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. Please attribute the source, use non-commercially, and maintain the same license.
输入关键词搜索文章内容