Back

Sep 11, 2024

Sep 11, 2024

Learn C# With the Help of Pieces

Jumpstart your C# learning with Pieces for Developers, an on-device AI assistant that can help you learn and stay organized.

C and Pieces logos.
C and Pieces logos.
C and Pieces logos.

Even though C# gets a lot of hate, it's actually a pretty awesome programming language. It's a great choice if you're looking to get into .NET development or create games with Unity. Plus, if you're new to programming, there are plenty of resources to help you get started.

One great resource is Pieces! Pieces is an AI-driven productivity tool that enhances developer workflows by managing code snippets and providing context-based interactions.

If that sounds complicated, don't worry! Even if you’re just starting to learn how to code, Pieces can be a great study buddy.

Let's get started!

Setting Up Your Development Environment

To get started with C# development, you'll need an Integrated Development Environment (IDE). In this article, we'll use Visual Studio, but you can use any IDE you prefer.

To make things easier, let's use Pieces to guide us through the setup.

If you haven’t installed Pieces yet, check out our guide on getting started with Pieces!

After you have Pieces installed, open the Pieces Desktop App and ask Pieces Copilot to "Guide me through setting up Visual Studio for C# development":

Pieces for Developers desktop application.

Then, follow the setup instructions, and don't hesitate to ask Pieces for more information if you get stuck.

After setting up your IDE, be sure to install the Pieces Visual Studio extension (or VS Code extension).

Hello, Pieces!

Now that our environment is set up, let's create our first C# program:

Pieces for Developers desktop application showing "How can I create a Console App project in Visual studio?

Here, we are asking Pieces how to create a new project in Visual Studio.

According to the instructions, all you need to do is open up Visual Studio and create a new Console App project.

After clicking “create”, you should see this in your IDE:

Console.WriteLine("Hello, World!");

This small piece of code will allow us to print something to the console, but in this case, we don’t want to print “Hello, World!”. Let’s change it to “Hello, Pieces!” 😉

Now, let's save the snippet:

IDE view of the code.

To save a snippet, all you need to do is highlight the piece of code, right-click, hover over “Pieces” in the dropdown menu, then click “Save to Pieces”. After this, the snippet will be saved in “Saved Materials”.

Now that we have officially saved our first C# snippet, let's run the program!

Running the program.

Congrats! You just wrote your first line of C# code (and saved it!). But there's a lot left to learn, so we should probably create some kind of learning roadmap to make sure we are going in the right direction with our C# studies.

C# Learning Roadmap

When we learn something new, the best place to start is by creating a roadmap. One site I recommend using for learning roadmaps is roadmap.sh; however, they don’t have a C# roadmap yet. So let's just ask Pieces to help us generate one:

Asking Pieces to create a C# learning roadmap for beginners.

Here, we open Pieces and ask it to "Create a comprehensive C# learning roadmap for beginners."

With this roadmap, you'll have a clear guide as you learn new concepts. Make sure to save it somewhere, like in a notes app or in Pieces’ Saved Materials, so you can track your progress and update it as you continue learning.

C# Learning Resources

In addition to having a roadmap, you need to have some solid resources to use when studying. Combining a roadmap while leveraging a suitable resource is the recipe for success when it comes to learning C# (at least I think so).

We already have our roadmap, so we just need to ask Pieces to "Please recommend some C# learning resources for beginners":

Pieces recommending some C# learning resources.

To find resources that suit your learning needs, you could tell Pieces what format you prefer. For example, if you learn best through watching videos, you could ask it to suggest video-based resources.

Personally, I learn best through hands-on/project-based learning and it needs to be mostly text-based (not a big fan of videos, what can I say?). If you’re in the same boat, definitely check out these resources (they are my favorite!):

FreeCodeCamp/Microsoft C# Certification:

  • Complete coding challenges and save your solutions in Pieces

  • Use tags to organize snippets by certification sections

"The C# Player's Guide" by RB Whitaker:

  • As you work through the book, save code examples and challenges in Pieces (this book is super cool if you like gamified learning)

Leveraging Pieces to Learn C#

We’ve mentioned Saved Materials a few times, but what even is that? Well, you could think of it as your own personal coding knowledge database. This is where you can save new syntax that you learn, code that you reuse a lot throughout projects, and maybe even some code that you want to send to your friends or classmates later on.

Building Your C# Snippet Library

One of the main things people add to their Saved Materials is code snippets. When you’re just starting to learn C#, you might add snippets like these:

Variables and Data Types:

int age = 19;
string name = "Snowflake";
bool isCat = true;
double heightInCm = 26.45;

If Statements:

// If statement
if (age >= 18)
{
    Console.WriteLine("You are an adult");
}
else
{
    Console.WriteLine("You are a minor");
}

For Loops:

for (int i = 0; i < 5; i++)
{
    Console.WriteLine($"Iteration {i}");
}

After you save some more snippets, your library will begin to look like this:

List View of Pieces for Developers desktop app.

Over time, your Saved Materials will become a great resource for reviewing and understanding new syntax.

To get the most out of your new knowledge library, make sure to try out different study methods. For example, you can use the Discover Related feature to find similar pieces of code, helping you see how different syntax is applied in various contexts.

Also, if you ever forget what a particular piece of code does, you could always click the Start a Copilot Chat button, and Pieces will clear up any confusion that you might have.

Then, if you ever need to find your old snippets, It’s super easy to retrieve them since Pieces auto-generates related tags. If you want to get even more specific, you can even add custom tags. This tagging system makes it simple to build up an extensive, easy-to-search, personalized code library.

Collaborative Learning

We’ve talked about saving pieces of code, but what about sharing them? Pieces has a really easy way to help with that:

Context view of Pieces.

Here, we choose the snippet that we want to share. Then, we click the Generate Shareable Link button to get our Personal Link. When you send this link to someone, they will be able to see your code snippet and the context associated with it (pretty neat, right?).

Apply What You Learn

Once you’ve saved lots of snippets and gotten comfortable with the basics of C#, it’s a good idea to start building some simple projects.

Creating projects is one of the best ways to reinforce what you've learned. But what if you don't have a good idea for a project? That's where Pieces comes in:

Pieces suggesting 5 beginner C# projects.

Here, we ask Pieces to "Suggest 5 beginner C# projects that use loops, conditionals, and basic data structures. I love wizards, cats, and League of Legends. (do not include any code)".

Just make sure to change the “wizards, cats, and League of Legends” part and make it relevant to your interests. After that, you can review its suggestions and choose one that interests you.

As you work on your project, remember to:

  • Save reusable code snippets

  • Use the "Pieces: Comment" feature

  • Use the “Pieces: Explain” feature

  • Share challenging parts of your code with mentors or peers

  • Use Pieces to help with when you run into issues or bugs (which will undoubtedly happen at some point)

  • Ask Pieces for code reviews

If you’re interested in learning about more ways to use Pieces, make sure to check out our other blog Why Students Should Use Pieces for Developers

After creating your first C# project, keep learning and building more projects. And don’t forget to use the snippets you've saved along the way!

Conclusion

Hopefully, as you read through this article, you realized that using Pieces while learning C# goes beyond just saving snippets - it's about creating your own coding knowledge library that expands as you learn new things.

From helping with setup, guiding you through your first project, or recommending resources, Pieces is there to make things easier. So keep on saving, organizing, and revisiting what you’ve learned. You’ve got this! Happy coding!



Ellie Zubrowski
Ellie Zubrowski

Written by

Written by

Ellie Zubrowski

Ellie Zubrowski

SHARE

SHARE

Learn C# With the Help of Pieces

Title

Title

our newsletter

Sign up for The Pieces Post

Check out our monthly newsletter for curated tips & tricks, product updates, industry insights and more.

our newsletter

Sign up for The Pieces Post

Check out our monthly newsletter for curated tips & tricks, product updates, industry insights and more.

our newsletter

Sign up for The Pieces Post

Check out our monthly newsletter for curated tips & tricks, product updates, industry insights and more.