#List類型的定義
from System.Collections.Generic import List, Dictionary
int_list = List[int]()
#同樣Byte類型的值的定義
from System import Byte
b = Byte(1) #
#同樣Byte類型的值的定義
from System import Byte
b = Byte(1) #
2.
C# lambada
>>> from System.Collections.Generic import IEnumerable, List
>>> list = List[int]([1, 2, 3])
>>> import clr
>>> clr.AddReference("System.Core")
>>> from System.Linq import Enumerable
>>> Enumerable.Any(list,lambda x:x<2)
True
>>> Enumerable.Any(list,lambda x:x>2)
True
>>> Enumerable.Any(list,lambda x:x>4)
False
3. C#中的byte[]數組,在Ironpython中這樣表示
from System import Array,Byte
bbyte = Array[Byte]
from System import Array,Byte
bbyte = Array[Byte]
4. ref 和 out
>>> from System.Collections.Generic import Dictionary
>>> d = { "a":100.1, "b":200.2, "c":300.3 }
>>> d = Dictionary[str, float](d)
>>> d.TryGetValue("b")
(True, 200.2)
>>> import clr
>>> r = clr.Reference[float]()
>>> d.TryGetValue("b", r)
True
>>> r.Value
200.2
>>>