Getting Started with DotNet Interactive Jupyter Notebooks 6 7 Visual Studio 2022

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey everyone have you ever started programming in net and c-sharp and you just needed to write some dot-net and you wanted to see the output in the console um in some other form and the only way for you to do that is to either make a console application go to a website online and plop in the dotnet to like sorry pop in the c sharp to see what the results of that are wouldn't it be great if you know visual studio 2022 had something baked in like like a scratch or a notepad well they do and it's growing in popularity just the way of being able to write c sharp just like a javascript scripting language and get the output right there in front of you without having to run anything and see anything so here i have a a dot net new of a blazer webassembly application and why i started investigating this is once i saw some microsoft videos and i was like yeah that looks like a pretty cool thing i'd like to incorporate that and then i i never really had a need for it but then i did the other day so i thought it was perfect so um let me just quickly just add a c-sharp file add new empty file which is a cool extension from mads so i'll say date functions and we'll use like the top level statements sorry not top level statements the um file scope namespaces and i wanted to do something simple like um get and get days between and that'll take date time d1 and datetime d2 all right so let's say we have this date functions and we have this get date between i had was i couldn't remember when you do the date add or the two time spans to get the difference between two dates for days hours months like what order i need to did i have to put the more recent date at the front or the back so i was like oh that would be a good use case for the microsoft implement implementation of the jupyter notebooks um so basically what i was trying to do is like figure out like i basically wanted to do you know if um or i don't have to do that so i'll just basically say d1 minus d2 dot days and i basically was setting like break points so option one equals and then option two and i would you know i'd set a breakpoint at the end return option one it doesn't i'll just say return zero um because i i couldn't remember you know for what order they have to be because i wanted to get the positive days right so um long story short basically what you have to do is like two things that worked for me and i'll put a link um in the description below first you have to add an extension from microsoft and i'll just go to the installed one so you can see so it's notebook editor preview and allows you to write the jupyter notebooks and have like a compilation in it um and then you also have to yeah so the you just have add the extension you don't necessarily have to get it from marketplace here you can get it from right from visual studio and then the other one was the net interactive and basically i just copied this and i ran it from elevated command prompt um all right so basically like i'm thinking going forward what i'm gonna do is just keep a jupiter notebook in each solution and that way you can write scratches of c sharp all right so and i'll put the the link to um all of the different files on the microsoft github for net interactive i just took their their course 101 file and i stripped out everything and then just added this adding days example so this is pretty helpful you can imagine that let's say you're writing this and you're like oh yeah i can't really remember how to do that like ideally they have something in visual studio where you could actually just say you know open i know when you're actually debugging you can do immediate windows so you can write you know c-sharp right there um i'm not sure if you can do it like so this is pretty pretty awesome and new and um so i'm pretty sure you can do it if you can let me know in the comments below i'd love to just open something here and just write c sharp but basically with these guys you can you know do markdown and what i did here with this i just said adding days example and then you can like store a bunch of kind of example um you know c-sharp and the cool thing about this is since it's using c-sharp and net interactive you can run it so if i have this and let's say var date diff and var date div 2 basically i can hit run and i can just see the values so i know that the one that is in the future you know this one here needs to come for uh first so it's basically saying hey take whatever now is add 15 so 15 days from now and then remove some minus actually now so it should be whatever and this is just 14 because of i assume because of the you know the difference of how it's being calculated between the times and midnight and stuff um but pretty cool so then i know that i'm like okay i just need the one and i would kind of you know if that's the second one and the first one is the first one then you know i would essentially just i would know right away um without having to um actually debug go through it's like oh i have it backwards like this is this is maybe an example that you know maybe some people know right away like for the when you're doing a time span and then you're calling a function on it um actually if you look here um uh yeah the day component return value can be positive so you know it doesn't say to me like which one so i'd have to run it to debug right so that's the beauty about these and you can kind of organize them it's kind of nice like you can go over here and i would go new mark down and i would say you know i just wanted to write something so i'd say c sharp scratch or just say notepad no pad okay and then here i'm gonna go code and then i'm just gonna say var test equals this is a um cool test go here and then i'll say console and you see how it with the jupiter notebooks you get the intellisense which is nice so console.writeline and then i'll say the word test and do that and now i can go to run and this is a cool test um yeah so you can you know do a whole bunch of things in there you know for loops right functions you can do classes as far as i'm aware like it's pretty powerful just to be able to write some c sharp like you would you know javascript or any kind of client-side language that you can see right away i'm sure there's some strongly typed languages so you can do that right away that you don't need to you know run and stuff like that um so yeah i hope you guys um like this cool way of um kind of testing out your c sharp before you implemented it in any files functions extensions and what what not um you can also like make um you know folders of kind of examples of like what you know what you're trying to achieve and and how to do them so for example if you if you had this you could actually paste that in there and call it you know then down here you know you could just say new var date function equals new date functions okay and then um you would basically say df dot get days between and then pass in date time now or just daytime now all right because i'm returning zero pretty cool i was like why is that working let's try it again there you go so cool really nice uh way of just kind of writing c sharp without actually hitting that big scary green button that if you have a bunch of things in your solution that takes long to start and you're waiting to log in and hit a break point this is awesome this is cool jupiter notebooks right in visual studio 2022 community hope you guys uh like this video uh subscribe if you found it helpful and useful i'll put all of the links to the various um things that you need to get going with this in the description and see you next time
Info
Channel: Logan Dunning
Views: 3,360
Rating: undefined out of 5
Keywords:
Id: X4lgkIOANhs
Channel Id: undefined
Length: 11min 4sec (664 seconds)
Published: Thu Jun 09 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.