[Python.NET] Is it possible to access the C# keywords?

Brian Lloyd brian at zope.com
Sun Jul 17 18:31:43 CEST 2005


> First off, python for .net is a great tool.  Tks vm, Brian.  
> My question is,
> I cant figure out how to access the C# keywords.  Is that 
> possible?  For
> instance, on the python side, I want to do something like 
> this C# snippet:
> 
>      Type type = typeof(One_Of_My_CSharp_Classes);
>      MemberInfo[] member_info = type.GetFields();
> 
> But I cant figure out how to access the C# keyword "typeof".  Neither
> CLR.typeof nor CLR.System.typeof works.  Is there a way to do this?

You can't use C# keywords per se (they are really just tokens 
with special meaning to the compiler and dont have a runtime 
representation), but you can do what you want with something 
like:

import CLR
from CLR.System import Type

mytype = Type.GetType("MyNamespace.MyType")
fields = mytype.GetFields()
...

hope this helps,

Brian Lloyd        brian at zope.com
V.P. Engineering   540.361.1716              
Zope Corporation   http://www.zope.com 
  



More information about the PythonDotNet mailing list