小方法

作者: 萧晨XC | 来源:发表于2018-11-14 16:33 被阅读0次

// 集合返回字符串

public static string ReturnString(List<string> content)

    {

        string strArray = string.Join(",", content.ToArray());

        return strArray;

    }

//字符串转换成int数组

public static int[] ReturnIntArr(string content)

    {

        int[] list;

        if (content == "" || content == null)

        {

            list = new[] { -1 };

        }

        else

        {

            list = Array.ConvertAll<string, int>(content.Split(','), s => int.Parse(s));

        }

        return list;

    }

//字符串是否包含在枚举中

Enum.IsDefined(typeof(枚举), "字符串")

//根据值 获得枚举名字

string name = Enum.GetName(typeof(枚举), index)

//根据名字实例化对象

类= ("类名")Assembly.GetExecutingAssembly().CreateInstance("命名空间." + "类名");

//根据名字调用方法

this.GetType().GetMethod("方法名").Invoke(this, null);

相关文章

网友评论

      本文标题:小方法

      本文链接:https://www.haomeiwen.com/subject/lupjfqtx.html