我有一堆属性的结构。所有属性都有一个名为someMethod()的对应方法。我试图为结构中的每个属性调用该方法。除了struct之外,我需要能够做到这一点。这甚至可能吗?
public class someStruct()
{
public int prop1{get, set}
public int prop2{get, set}
public int prop3{get, set}
}
这显然不是我的代码,但是重点突出。假设每个prop都有一个add()。我通常可以这样做:
someStruct example = new someStruct();
example.prop1.add();
example.prop2.add();
example.prop3.add();
但我需要一个方法,我可以传递示例,它将为每个属性调用add()。最终目标是拥有一个名为callAdds的方法:
callAdds(example);
答案 0 :(得分:-1)
try use
//if this is the only format of date and time then you can use,
Regex stringDatePattern=new Regex("*[0-9][0-9][/][0-9][0-9][/][0-9][0-9[0-9][0-9]]*");
return stringDatePattern.IsMatch(TextBox.Text);
//Split the string
Regex.Split Method (String, String, RegexOptions);