ソースコード:SetHelpers.SetToString()

静的クラス SetHelpers では、クラス SetCollection/FrozenSetCollection で共有するメソッドを支援する、補助的な処理群(Helpers)を実現します。

    /// 
/// Contains common set functionality between set and forzenSet
///

static class SetHelpers {
public static string SetToString(object set, IEnumerable items) {
string setTypeStr;
Type setType = set.GetType();
if (setType == typeof(SetCollection)) {
setTypeStr = "set";
} else if (setType == typeof(FrozenSetCollection)) {
setTypeStr = "frozenset";
} else {
setTypeStr = Ops.GetDynamicType(set).Name;
}
StringBuilder sb = new StringBuilder();
sb.Append(setTypeStr);
sb.Append("([");
string comma = "";
foreach (object o in items) {
sb.Append(comma);
sb.Append(Ops.Repr(o));
comma = ", ";
}
sb.Append("])");

return sb.ToString();
}

これらのメソッドは static 宣言してあり、メソッド呼び出しの対象となるインスタンス自身(実引数 this)が、仮引数 set になります。つまり、static 宣言することで、一連のメソッドを「関数」として再定義するのです。