Get all defined Variables in the current context programatically? #3044
Replies: 1 comment
-
Here's an example of the API used to query for which variables are declared in a given kernel: using Microsoft.DotNet.Interactive;
using Microsoft.DotNet.Interactive.Commands;
var result = await Kernel.Root.SendAsync(new RequestValueInfos("csharp"));
result.Events The To get the value of a specific variable you can use the var result = await Kernel.Root.SendAsync(new RequestValue("x", mimeType: "application/json", targetKernelName: "csharp"));
result.Events It's also worth noting that the |
Beta Was this translation helpful? Give feedback.
-
Is there any way to get the Variables programatically (i.e. in a C# cell)? (I know you see it in the Polyglot Notebook: Variables pane)
I want to run a different code path depending on whether a variable exists in the Notebook.
Thanks
Beta Was this translation helpful? Give feedback.
All reactions