0

在下面的课程中,我有时想为属性“BodyParameters”传递一个字符串数组。如果不使用对象类型作为其参数类型,这可能吗?大多数情况下,当使用该类时,此属性将是一个字符串 [ ] 数组列表。

public class EmailTemplate
{
    ...
    public IList<string[]> BodyParameters { get; set; }
    ...
}
4

1 回答 1

1

如果你想BodyParameters只使用一个设置string[],你可以这样做:

string[] value = ...;
myEmailTemplate.BodyParameters = new [] { value };

在您的情况下,没有从Tto的隐式转换。IList<T>Tstring[]

上面的代码会起作用,因为new [] { ... }会推断出string[][]实现的类型IList<string[]>

于 2014-03-29T16:51:36.483 回答