public sealed class Add : CodeActivity<int> { [RequiredArgument] public InArgument<int> Operand1 { get; set; } [RequiredArgument] public InArgument<int> Operand2 { get; set; } protected override int Execute(CodeActivityContext context) { return Operand1.Get(context) + Operand2.Get(context); } } 在 XAML 中,也请使用 RequiredArgumentAttribute 来指示所需参数。下面的示例定义了一个含有三个参数的 Add 活动,并使用 Assign 活动执行添加操作。