0

Assume the following code:

public class Foo
{
    public string Bar { get; set; }
}

How can I instantiate an instance of Foo in the following code?

ScriptRuntimeSetup setup = Python.CreateRuntimeSetup(null);
ScriptRuntime runtime = new ScriptRuntime(setup);
ScriptEngine engine = Python.GetEngine(runtime);
ScriptScope scope = engine.CreateScope();

string script = @"x = ***???***";
ScriptSource source = engine.CreateScriptSourceFromString(script, SourceCodeKind.Statements);
source.Execute(scope);

1 Answer 1

1
string script = @"
  import clr
  clr.AddReference('FooNamespace')
  from FooNamespace import *
  x = Foo()";
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.