Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 仅从给定字符串获取参数名称_C#_String - Fatal编程技术网

C# 仅从给定字符串获取参数名称

C# 仅从给定字符串获取参数名称,c#,string,C#,String,仅从上面的字符串获取参数名称,如type1、type2、art5等 我应该如何操作字符串mystring=“Display(string type1)”; string mystring = "Display(String type1, String type2, String art3, String ar4, String art5, String art6, String arg7)" 字符串mystringValue=@“1”; string s=mystring.Replace(“s

仅从上面的字符串获取参数名称,如type1、type2、art5等

我应该如何操作字符串mystring=“Display(string type1)”;
string mystring = "Display(String type1, String type2, String art3, String ar4, String art5, String art6, String arg7)"
字符串mystringValue=@“1”; string s=mystring.Replace(“string”,string.Empty).Replace(“)”,string.Empty).Replace(“(”,“,”,”); 字符串[]s2=s.Split(','); ArrayList myArrayList=新的ArrayList(s2); myArrayList.RemoveAt(0); 字符串[]s3=mystringValue.Split(','); 列表=新列表(); int指数=0; foreach(myArrayList中的字符串名称) { PropertyInformation p=新的PropertyInformation(); p、 名称=名称; p、 值=s3[指数]; 增加(p); 索引++; }
创建字符串后,您无法获取参数。您想在这里做什么?您能显示显示类吗?重复?它是字符串而不是类
string mystring = "Display(String type1)";
            string mystringValue = @"'1'";

            string s = mystring.Replace("String", string.Empty).Replace(")", string.Empty).Replace('(', ',');
            string[] s2 = s.Split(',');

            ArrayList myArrayList = new ArrayList(s2);           
            myArrayList.RemoveAt(0);

            string[] s3 = mystringValue.Split(',');

            List<PropertyInformation> list = new List<PropertyInformation>();
            int index = 0;
            foreach (string name in myArrayList)
            {
                PropertyInformation p = new PropertyInformation();
                p.Name = name;
                p.Value = s3[index];
                list.Add(p);
                index++;
            }