Search code examples
c#pythontypeslong-integerint64

Getting C# Int64 in Python


I have to get an Int64 object in Python. My code looks like this:

from System import Int64
l = Int64.Parse('123')
print(l, type(l))

but it returns: 123 <class 'int'>

When I did the same with DateTime c# object, it returned just right type: <class 'System.DateTime'>

So why does Python convert an Int64 C# object back to it's own int class?

I need exactly this type, because I'm sending it to external program, which otherwise fails.

Thanks a lot.


Solution

  • Figured out a way, but it's quite a harakiri:

    Int64.__new__(Int64, value)