1+1
Console
using System.Threading.Tasks;
using Microsoft.DotNet.Interactive;
var output = string.Empty.Display("text/plain");
var counter = 1;
while (!KernelInvocationContext.Current.CancellationToken.IsCancellationRequested)
{
await Task.Delay(500, KernelInvocationContext.Current.CancellationToken);
output.Update($"{counter++}");
}
var x = 123;
The value is not yet set.
#!share --from csharp x
document.getElementById("output").innerText = `The value is ${x}.`;
console.log(`The value is ${x}.`);
#!set --value @csharp:x --name y
y++;
document.getElementById("output").innerText = `The value is ${y}.`;
console.log(`The value is ${y}.`);
const jsKernel = kernel.root.findKernelByName('javascript');
console.log(jsKernel.name);
kernels = Array.from(kernel.root.findKernels(s => true).map(k => k.name)).sort();
return kernels;
await kernel.root.send({ commandType: 'SubmitCode', command: { code: 'var csharpVarFromJs = 1234; Console.WriteLine(csharpVarFromJs);', targetKernelName: 'csharp' } });
let command = new polyglotNotebooks.KernelCommandEnvelope(polyglotNotebooks.SubmitCodeType, { code: 'var csharpVarFromJsUsingApi = 2345; Console.WriteLine(csharpVarFromJsUsingApi);', targetKernelName: 'csharp' });
await kernel.root.send(command);
var value = new { Name = "Developer", Salary = 42 };
value.Display("application/json", "text/html");
10m + 21.1m
#!share --from pwsh undefinedVariableName
1+1
let x = 1 +
Console.Write("\x1b[38;2;0;255;0m");
Console.WriteLine("this is green");
Console.Write("\x1b[0m");
"this is white".Display();
Console.Error.Write("\x1b[38;2;255;0;0m");
Console.Error.WriteLine("this is red");
Console.Error.Write("\x1b[0m");
var input = await Microsoft.DotNet.Interactive.Kernel.GetInputAsync("give me data");
input
let input = (task {
return! Microsoft.DotNet.Interactive.Kernel.GetInputAsync ("give me data")
}).Result
input
#!value --from-value @input:wat --name value_from_input
#!share --from value value_from_input
value_from_input
#!set --name csharpVarFromInput --value @input:"Please enter a value"
csharpVarFromInput
mindmap
root((.NET Interactive))
Commands
SubmitCode
Cancel
SendValue
Events
CommandSucceeded
CommandFailed
ValueProduced
Kernels
Kernel
CompositeKernel
ProxyKernel
Directives
Connect
SQL
KQL
Jupyter
using Microsoft.DotNet.Interactive;
using Microsoft.DotNet.Interactive.Commands;
var _ = Kernel.Root.SendAsync(new SendEditableCode("fsharp","#!share --from csharp x\nx"));
using Microsoft.DotNet.Interactive;
using Microsoft.DotNet.Interactive.Commands;
for(var i = 0; i<2;i++){
var _ = await Kernel.Root.SendAsync(new SendEditableCode("markdown",$"# markdown cell {i}"));
}