Have you checked out the new Blazor Web Application projects in Visual Studio 2022 Preview? This is huge for .NET web development! And I'll cover it in my @OReillyMedia live training course next month.
There are still open slots—register today!
learning.oreilly.com/live-ev…
A random test drive! We use the .NET Random class throughout Head First C# (@OReillyMedia). Here's how we help you get to know it better by kicking its tires and taking it for a spin.
From Head First C# by @AndrewStellman and @JennyGreene
Why would I want to use an interface in C# instead of just writing all of the methods I need directly into my class?
Answering your questions about interfaces in Head First C# (@OReillyMedia) by @AndrewStellman and @JennyGreene
XAML is an important building block for many C# apps. A lot of people have questions about it—we answer them in Head First C# (@OReillyMedia) by @AndrewStellman and @JennyGreene.
Top-level statements were added to C# just after we finished the 4th edition of Head First C# (@OReillyMedia). They totally changed how we teach important ideas in our new edition—and they have a really valuable lesson for anyone who wants to learn (or teach!) coding.
Curious?
ALT Image from the upcoming edition of Head First C#
Every C# program’s code is structured in exactly the same way. All programs use namespaces, classes, and methods to make your code easier to manage.
When you create your app, all of the code is inside a namespace. This helps keep your classes are separate from the ones that come with .NET.
A class contains a piece of your program. Some very small programs can have just one class, but most have more.
A class can have fields. A field is a variable, except that it’s declared outside of the methods so all of the methods in the class can use it.
A class has one or more methods. Your methods must live inside a class. The order of the methods in the class file doesn’t matter. Method 2 can just as easily come before method 1
Methods are made up of statements—like ones you used in your apps in the last two chapters.
Happy Sunday afternoon! Looking for a quick, fun project to practice your C# skills on Windows or Mac? Try the Animal Matching Game from Head First C# (@OReillyMedia).
Download the free PDF from our GitHub page to get started! github.com/head-first-csharp…
Just updated one of my favorite parts of Head First C# (@OReillyMedia) for the next edition teaching about paper prototypes!
The book is about learning C#—but we also want to help our readers become better developers. This is a great opportunity to teach a really useful skill.
ALT Excerpt from Head First C#. A paper prototype of a screen from Super Mario Brothers.
Annotations:
The text at the top of the screen is called the HUD, or head-up display. It’s usually drawn on the background in a paper prototype.
When the player catches a mushroom he grows to double his size, so we also drew a small character on a separate scrap of paper.
The ground, bricks, and pipe don’t move, so we drew them on the background paper. There’s no rule about what goes on the background and what moves around.
The mechanics of how the player jumps were really carefully designed. Simulating them in a paper prototype is a valuable learning exercise.
Another win for the 5th edition of @HeadFirstCSharp. In the 4th ed. I worked closely with folks from the @VisualStudioMac team—especially @jongalloway, a real privilege!—to support VS for Mac. Thanks to MAUI, I can move all that material out of an appendix and into the main book.
ALT Excerpt from Head First C#:
Create your first project in Visual Studio – Mac edition
The best way to learn C# is to start writing code, so you’re going to write a lot of code—and create a lot of apps!—throughout this book. Each app will get its own project, or a folder that Visual Studio creates with special files to organize all of the code. Follow these steps to create the Console App projects in this book.
Working with MAUI has been such a pleasure. The best part is that our readers can write apps for their mobile devices again! We had a Windows Phone (RIP 😢) game in the 3rd edition, and I loved that.
Super grateful to @pureween and @maddymontaquila for the assist with MAUI code!
ALT Excerpt from Head First C#:
MAUI apps work on all of your devices
MAUI is a cross-platform framework for building visual apps, which means the apps that you build can run on your Android and iOS devices. If you have an Android phone or tablet, for example, you can set it to developer mode, plug it into your computer, and tell Visual Studio to deploy the app straight to your phone. You can do the same thing with your iPhone or iPad, but Apple requires you to join the Apple Developer Program before you can do that—at the time we’re writing this costs USD $99 (although nonprofits, government agencies, and students can get a fee waiver).
We just plugged in an Android phone in and deployed the .NET MAUI app to it... and it worked!
Working on making some really exciting changes in the next edition of @HeadFirstCSharp – especially moving to @dotnet MAUI. The more I use it, the more I love it!
We're diving right into writing fun apps, starting with a game. I love how it came out! 👀
ALT Excerpt from the next edition of Head First C#:
Let’s build a game!
You’ve built your first C# app, and that’s great! Now that you’ve done that, let’s build something a little more complex. We’re going to build an animal matching game, where a player is shown 8 pairs of animals and needs to click on them in pairs to make them disappear.
The game displays sixteen buttons with eight pairs
of matching animals in a random order. You play by clicking animals in pairs: first click one animal, then click its match. Match all eight animals and you win the game!
Working on the next edition of Head First C#. One of the big changes is that we're switching from WPF to .NET MAUI for our apps that have a user interface—and I am LOVING IT! One of my favorite things is it gives me a chance to talk about #accessibility#a11y from the beginning.
ALT Excerpt from the upcoming Head First C#. Image of two people in wheelchairs holding coffee mugs. Text says:
SemanticProperties help you make your apps accessible
When we create our apps, we want everyone to be able to use them—and that includes people with disabilities.
A screen reader is a tool that lets people who are blind, visually impaired, or have learning disabilities or other conditions that interfere with their ability to read use our visual apps. Semantic properties help your app work with a screen reader.
Annotation pointing to people says:
A screen reader is an accessibility tool for people with visual, learning, or other disabilities—just like a wheelchair is an accessibility tool for people with mobility-related disabilities. They’re both really important for helping to make everyday things more accessible to everyone.
You can use the static File and Directory classes in @dotnet to work with files and directories. If you want to work with an object, use FileInfo instead of File.
Working with files in @HeadFirstCSharp (@OReillyMedia) by @AndrewStellman and @JennyGreene
I got the feedback from the folks at O'Reilly online learning about my latest #Blazor live training workshop that I ran for them. People really liked it! Everyone gave it either a 9/10 or 10/10 (except for one 8/10), and the comments were really positive!
Every Unicode character—including emoji—has a unique number called a code point. You can download a list of all of the Unicode characters here: unicode.org/Public/UNIDATA/U…
Demystifying Unicode and UTF8 in Head First C# (@OReillyMedia)
When you're learning C#, @VisualStudio and @VisualStudioMac are fantastic tools to help you learn and explore. We use them throughout Head First C# (@OReillyMedia) as learning tools.
Quick project from Head First C# (@OReillyMedia): build a C# program that uses a Dictionary to store retired baseball jerseys.
A Dictionary can have duplicate values, but every key must be unique. Can you think of a way to store retired numbers for multiple teams?
A paper prototype can be a valuable first step in designing a video game—and if you've played tabletop games, you might find them really intuitive!
Exploring paper prototypes in Head First C# (@OReillyMedia)
x.com/HeadFirstCSharp/status…
"Paper prototypes are really useful for helping you figure out how a game will work before you start building it, which can save you a lot of time. … All you need is some paper and a pen or pencil."
Learning about paper prototypes in Chapter 3 of Head First C# (@OReillyMedia)
ALT A paper prototype of a classic game, from Chapter 3 of Head First C# (O'Reilly Media) by Andrew Stellman and Jenny Greene
Interested in building full-stack web applications with C# and .NET? There are still slots left for my Blazor Fundamentals training session on @OReillyMedia Learning!
I'm super excited to teach this fast-paced workshop on Friday. Hope to see you there!
oreilly.com/live-events/blaz…
ALT Screenshot of my "Blazor Fundamentals... Just Enough to be Dangerous" course listing