简体   繁体   中英

Pythonnet (clr) and C# lists and enums

I have myClass which contains a field myList which is a list of elements from myEnum . I would like to add to this list more elements but in python. However exec(f"myClass.myList.Add(myEnum.{e}))" doesnt work because myClass.myList in Python is a list of integers. What can I do? I want to add elements by its name, not its int position.

Switch to pytho.net 3.0 previews. In 3.0 .NET lists are not converted to Python lists, instead they just behave like Python lists when seen from Python.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM