Unlike cw (for Console.WriteLine) there is no shortcut available for Console.ReadLine in Visual Studio 2019. In this short post I will show you how I’ve created a snippet that binds cr to Console.ReadLine.
1. Save the following as .snippet somewhere on your computer.
<?xml version="1.0" encoding="utf-8" ?> <CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> <CodeSnippet Format="1.0.0"> <Header> <Title>cr</Title> <Shortcut>cr</Shortcut> <Description>Code snippet for Console.ReadLine</Description> <Author>Whoever you want it to be</Author> <SnippetTypes> <SnippetType>Expansion</SnippetType> </SnippetTypes> </Header> <Snippet> <Declarations> <Literal Editable="false"> <ID>SystemConsole</ID> <Function>SimpleTypeName(global::System.Console)</Function> </Literal> </Declarations> <Code Language="csharp"><![CDATA[$SystemConsole$.ReadLine();]]> </Code> </Snippet> </CodeSnippet> </CodeSnippets>
2. Click on Import… and find the .snippet file you just saved
3. Click Finish
Now if you type cr and hit tab twice (just like cw) you’ll have your Console.ReadLine. Cool!
6 thoughts on “Creating Console.ReadLine Snippet in Visual Studio 2019”
Thanks A lot Dear Sir for Console.ReadLine snippet. I am 52 Years Old Man. and interested in learning Csharp and I am trying to understand programming logic by looking different YouTube Tutorials. any suggestion for me dear sir . Hope you will reply me. Thanks in advance
Thanks for stopping by.
YouTube has tons of useful content regarding C# and programming in general.
Another great place that you should definitely check out is Microsoft’s official documentation which is probably your best bet as it’s updated regularly and written by experts.
Here is the their website: https://docs.microsoft.com/en-us/dotnet/csharp/
Thank you. You solve my issue in a simple way. greetings from my end.
It detects nothing in the folder..do i need to save the file in a text doc?
yes text doc is fine but save with .snippet
Thank you very much 🙂