C# 从结构中调用属性方法

C# 从结构中调用属性方法,c#,struct,structure,C#,Struct,Structure,我有一个有很多属性的结构。所有属性都有一个名为someMethod()的对应方法。我试图为结构中的每个属性调用方法。我需要能够做到这一点,没有任何东西,除了结构。这可能吗 public class someStruct() { public int prop1{get, set} public int prop2{get, set} public int prop3{get, set} } 这显然不是我的代码,但能让人明白这一点。假设每个道具都有一个add()。我通常可

我有一个有很多属性的结构。所有属性都有一个名为someMethod()的对应方法。我试图为结构中的每个属性调用方法。我需要能够做到这一点,没有任何东西,除了结构。这可能吗

public class someStruct()
{
    public int prop1{get, set}
    public int prop2{get, set}
    public int prop3{get, set}
}
这显然不是我的代码,但能让人明白这一点。假设每个道具都有一个add()。我通常可以做:

someStruct example = new someStruct();
example.prop1.add();
example.prop2.add();
example.prop3.add();
但我需要有一个方法,在这个方法中我可以传入示例,它将为每个属性调用add()。最终目标是拥有一个名为callAdds的方法:

callAdds(example);

你为什么有这些方法?为什么不直接访问属性?这些方法是做什么的,它们是如何与属性关联的?你能给我看一些代码吗?现在不可以。我有很多不同的结构需要做同样的事情。我相信这是可能的,但没有一个例子作为参考是不可能的。事实上,有一个简短但完整的例子,我相信它会相当简单…我想你是想把这篇文章放在一个不同的问题上。这与被问到的问题无关。
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);