本文整理汇总了C#中ISequence.__len__方法的典型用法代码示例。如果您正苦于以下问题:C# ISequence.__len__方法的具体用法?C# ISequence.__len__怎么用?C# ISequence.__len__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISequence
的用法示例。
在下文中一共展示了ISequence.__len__方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: stat_result
public stat_result(CodeContext/*!*/ context, ISequence statResult, [DefaultParameterValue(null)]PythonDictionary dict) {
// dict is allowed by CPython's stat_result, but doesn't seem to do anything, so we ignore it here.
if (statResult.__len__() < 10) {
throw PythonOps.TypeError("stat_result() takes an at least 10-sequence ({0}-sequence given)", statResult.__len__());
}
_mode = statResult[0];
_ino = statResult[1];
_dev = statResult[2];
_nlink = statResult[3];
_uid = statResult[4];
_gid = statResult[5];
_size = statResult[6];
_atime = statResult[7];
_mtime = statResult[8];
_ctime = statResult[9];
object dictTime;
if (statResult.__len__() >= 11) {
_st_atime = TryShrinkToInt(statResult[10]);
} else if (TryGetDictValue(dict, "st_atime", out dictTime)) {
_st_atime = dictTime;
} else {
_st_atime = TryShrinkToInt(_atime);
}
if (statResult.__len__() >= 12) {
_st_mtime = TryShrinkToInt(statResult[11]);
} else if (TryGetDictValue(dict, "st_mtime", out dictTime)) {
_st_mtime = dictTime;
} else {
_st_mtime = TryShrinkToInt(_mtime);
}
if (statResult.__len__() >= 13) {
_st_ctime = TryShrinkToInt(statResult[12]);
} else if (TryGetDictValue(dict, "st_ctime", out dictTime)) {
_st_ctime = dictTime;
} else {
_st_ctime = TryShrinkToInt(_ctime);
}
}
示例2: SequenceSliceAssign
private static void SequenceSliceAssign(SliceAssign assign, int start, int n, int step, ISequence lst) {
if (lst.__len__() < n) throw PythonOps.ValueError("too few items in the enumerator. need {0}", n);
else if (lst.__len__() != n) throw PythonOps.ValueError("too many items in the enumerator need {0}", n);
for (int i = 0, index = start; i < n; i++, index += step) {
assign(index, lst[i]);
}
}