Instantiating a python class in C#
Posted
by Jekke
on Stack Overflow
See other posts from Stack Overflow
or by Jekke
Published on 2009-02-23T20:47:25Z
Indexed on
2010/04/27
15:43 UTC
Read the original article
Hit count: 285
I've written a class in python that I want to wrap into a .net assembly via IronPython and instantiate in a C# application. I've migrated the class to IronPython, created a library assembly and referenced it. Now, how do I actually get an instance of that class?
The class looks (partially) like this:
class PokerCard:
"A card for playing poker, immutable and unique."
def __init__(self, cardName):
The test stub I wrote in C# is:
using System;
namespace pokerapp
{
class Program
{
static void Main(string[] args)
{
var card = new PokerCard(); // I also tried new PokerCard("Ah")
Console.WriteLine(card.ToString());
Console.ReadLine();
}
}
}
What do I have to do in order to instantiate this class in C#?
© Stack Overflow or respective owner