Features in C# 10 Which May Help Every Developer

No Comments »

C# 10 is the latest version of the C# programming language, widely used for developing desktop applications, web applications, games, and other software. C# 10 was released in November 2021 and introduced several new features and improvements over the previous version, C# 9. Some notable features of C# 10 include file-scoped namespaces, global using directives, improved support for interpolated strings, and extended support for pattern matching. Additionally, C# 10 consists of a number of performance improvements and other enhancements designed to make it easier and more efficient for developers to write high-quality code. It is one of the oldest and fast-growing programming languages in the world. Today we will discuss some top features in C# 10 that will help developers write code faster and prettier.

Using Global

The amount of code you need to write will be greatly decreased by this brand-new feature. You may be aware that the beginning of every C# program contains a list of “using” statements that are required for the implementations. However, this can occasionally be repetitive, especially if you’re working with ASP.NET, where a lot of this code gets recycled and acts as “noise” for programmers.

The global keyword is a further brand-new C# 10 feature. If you utilize them internationally, you can select global use for the entire project. In actuality, it is suggested that you create a separate file, such as using.cs, that provides these specifications. This suggests that the remaining project files could be condensed as they don’t have to contain all of these uses. This is referred to as “vertical (space) wastage” by C# developers.

Strings with constant interpolation

With the introduction of string interpolation in C# 6, it is now simple and convenient to apply syntax to a string. Typically, an interpolated string is made up of both strings and expressions. The expression is executed and the resulting string value is added in its place when an interpolated string is resolved to a string.

Back then, only strings could be interpolated; a string that has been declared as a constant cannot be. However, this capability of string interpolation is now available for strings that have been defined as constants in C# 10, with the restriction that only constant strings may be utilized in the expression.

Extended property patterns

A new feature called extended property patterns is very useful when dealing with nested properties. In the past, weren’t constructors used more explicitly? Nowadays, heavy builders are rarely made; instead, businesses use light builders, where the values of the properties are supplied immediately. In the most recent version of C#, 10, “Required” is a new term for properties. This allows users to make a property mandatory while defining a class. If you try to construct an object without the necessary property, you’ll receive an error at compilation time.

Namespaces for Files

The global keyword C# eliminates vertical waste, and the use of file namespaces eliminates horizontal waste. This feature’s primary goal is to fix the indent issues; however, it’s more of a visual improvement that should make your code appear lot nicer. The namespace can now be declared at the file level using this functionality.

To make use of this capability in all upcoming classes, perform the following actions in Visual Studio 2022:

  • Right-click the project first. Then, select New EditorConfig under Add.
  • Open the Editor configuration file at this time.
  • Click the Code Style tab.
  • Save the file after switching Namespace declarations from Block Spaced to File Scoped.
  • The file-scoped format will be used going forward for creating new CS files.

Checking for Null Parameters

The Null Reference Exception is one of the biggest mistakes your code may make. To avoid this kind of problem, your application architecture must be perfect and function parameter checks must be numerous. We might be able to avoid this problem and enhance the readability and resilience of our code thanks to this new functionality. The goal of the new C# version is to simplify this problem for us. Just after the parameter name, type “Bang bang” by placing two exclamation points. The program will automatically check to see if the newObject is null. The ArgumentNullException would be produced right away if the newObject value is null.

Enhanced #line pragma

The newest version of C#, 10, contains a new format for the #line pragma. You won’t likely use the new layout, but you will still see its impact. More precise outputs are now possible in domain-specific languages (DSLs) like Razor thanks to the advancements. These upgrades allow the Razor engine to enhance the troubleshooting process. You’ll see that debuggers can now highlight your Razor source more accurately.

Terms for the Field

Self-implemented properties have been since C# 3 and are not a new feature. The get and set attributes of the property are the only ways to access the private, anonymous field that the compiler creates once the program has been compiled. One of the exciting features of the current version of C# is an init accessor. With such an accessor, immutable objects gain a lot more flexibility by enabling the caller to change members while creating the object. The field introduced in the most recent edition is a new keyword in the C# programming language. In general, a new field would not be required as of C# Current version 10. This keyword could be used by the init accessor as well.

Conclusion

In this article’s discussion of the new C# features, we learned about some of them. Some of these seem to be substantial improvements, and they seem to have an effect on how we approach and develop C# projects.

Intro to C# Game Development

No Comments »

.NET is a cross-platform and open-sourced developer platform for building different types of applications. The tech-giant Microsoft developed it. It’s also designed for new developers trying to learn how to use .NET by making games. Here we will discuss why and what are the benefits of using .NET in game development. We will also talk about the different game engines in .NET and its tools, which make .NET a perfect choice for developing games. .NET is also part of Microsoft Game Stack, a comprehensive suite of tools and services just for game development.

Why use .NET in game development?

The major plus for .NET is that it is a cross-platform, a single code base can be used on different operating systems, be it Windows, MAC, or Linux. So developing a game in .NET means it is compatible with all these platforms.

.NET works seamlessly with game engines like Monogame and Unity, and many more. You can create incredible 2D and 3D games using these. Game engines and framework developers are using .NET to ensure secure cross-platform scripting for multiple gaming platforms. Another significant advantage is developing your game and its mobile application, website, and other online services using the same platform. So why not use .NET in game development.

What is a Game Engine?

Not so long ago, developers used to make their games from scratch, but now they have made a lot of reusable code in their games and have made APIs and tools they can reuse for each game. So whenever a developer is developing a new game, they can make use of all these.

A game engine is a software development environment designed to build video games. They contain abstraction of graphics, input, and media API. And also, asset managers and design tools for audio and visuals.

With the increasing popularity of C#, more engines are now being used .NET. The mono runtime compatible with .NET 5 can run C# code on many platforms like Android, iOS, Mac, etc. It is one of the main reasons for using .NET in game development.

Available game engines

The first step to developing games in .NET is to choose a game engine. You can think of engines as the frameworks and tools you use for developing your game. There are many game engines that use .NET and they differ widely.

Stride

It was developed by Silicon Studios, an utterly integrated engine with a graphic editor. It is a complete C# and .NET engine which is open-source and royalty-free. Another advantage is you can use parts of these engines independently

Mono Game

Mono Game is a very flexible engine; other game engines even use this as their base. FlatRedBall is an example of this. It can be used as a framework to build other game engines. Many game developers use it for their cross-platform game development.

Wave Engine

Another game engine that is fully developed in .NET is WaveEngine. It has a lot of reality features like spatial audio and ready to use out of the box. It has many of its components open-sourced and free.

NeoAxis

NeoAxis is yet another game engine written purely in .NET. It is also free and open-sourced. It supports a whole lot of features like the latest Android release

Online services for your game

If you’re building your game with .NET, then you have many choices on how to build your online game services. You can use ready-to-use services like Microsoft Azure PlayFab. You can also build from scratch on Microsoft Azure. .NET also runs on multiple operating systems, clouds, and services, it doesn’t limit you to use Microsoft’s platforms.

The ecosystem

The .NET game development ecosystem is rich. Some of the .NET game engines depend on foundational work done by the open-source community to create managed graphics APIs like SharpDX, SharpVulkan, Vulkan.NET, and Veldrid. Xamarin also enables using platform native features on iOS and Android. Beyond the .NET community, each game engine also has their own community and user groups you can join and interact with. .NET is an open-source platform with over 60,000+ contributors. It’s free and a solid stable base for all your current and future game development needs.

Rich set of .NET tools

.NET is vibrant in terms of game development tools. As it is an open-source platform with a rich community of developers and users. Most of the .NET engines also depend on the base of other open-source work. In addition to the community of .NET developers, each of these game engines also has a different user base. They need different kinds of tools according to their needs and .Net has a variety of tools to help them. .NET tools you are used to are also used for making games. Visual Studio is a great IDE that works with all .NET game engines on Windows and macOS. It provides word-class debugging, AI-assisted code completion, code refactoring, and cleanup. It works seamlessly with all of the game engines. In addition, it provides real-time collaboration and productivity tools for remote work. Another feature is assisted in code completion and cleanup. Also, it includes code refactoring. This perfect environment is the reason for the growing demand for .NET in game development. GitHub also provides all your DevOps needs. Host and review code, manage projects, and build software alongside 50 million developers with GitHub.

Conclusion

Indeed, the future of .NET in game development is bright. Game Engines use the latest versions of .NET, and it even gets upgraded as the new version releases. With strong game engines, a rich set of tools, and C# .NET’s growing popularity is gamers’ favorite. That’s why it has become one of the best choices for game developers.

DevURLs – A Neat Developer News Aggregator

No Comments »

Here’s an interesting new project. It’s called DevURLs and it’s a really nice developer news aggregator. It collects news stories from top 30 software development websites and programming blogs and presents it in a neat way.


devurls-developer-news-aggregator

This website is now my homepage and I visit it multiple times a day to get my daily dose of programming news.

Online Developer Tools

No Comments »

Here’s something that all you, my fellow C# developers, will find useful. Yesterday a company called Browserling announced that they’re launching a network of online developer tools.

If you haven’t heard about Browserling then you should check them out. They’re a friendly and fun cross-browser testing service and they’ve created and open-sourced over a hundred projects, including browserify for node.js.

Online developer tools network is a collection of websites where each website focuses on a single category of developer tools. Right now there are four websites in the network and they’re releasing 30 more websites over the next couple of years.

All websites in the network are ad-free. The reason why Browserling built this network is because their developers got fed up with other online services that offer similar tools. They were often filled with ads, popunders, blinking buttons and other crap. Browserling’s developers had had enough of this and they decided to create their own utilities that just work in your browser and do the right thing.

Let’s take a look at each site in more details.

Online String Tools


Online String Tools for Developers
String Tools for Developers

Online String Tools has hundreds of tiny string utilities for converting strings, generating strings, encoding/decoding strings, filtering and replacing strings and more. All string utilities work right in your browser. There is no server-side processing going on and everything is super fast.

Online JSON Tools


Online String Tools for Developers
JSON Tools for Developers

Online JSON Tools has two dozen utilities for working with JSON config files and JSON documents. Just like string tools, JSON tools work in your browser and are powered by modern JavaScript code, which makes them very fast. You can convert JSON to various data formats, encode and decode JSON, and compress, validate and prettify JSON.

Online XML Tools


Online XML Tools for Developers
XML Tools for Developers

Similar to string and JSON tools, this website offers two dozen utilities for working with XML configuration files and XML documents. All tools on this website also work inside your browser and nothing gets sent to the server. You can pretty much do all XML tasks with these tools. For example, you can compress XML, prettify XML and validate XML documents, and you can also convert XML to other data formats, such as YAML, TSV, CSV, JSON and Base64.

Online CSV Tools


Online CSV Tools for Developers
CSV Tools for Developers

Online CSV Tools offers over two dozen different utilities for working with CSV data files. All CSV data processing happens in the browser and it’s super fast. You can convert CSV to a bunch of other data formats, like JSON and YAML, then you can work with CSV columns and rows. You can insert rows, swap columns, as well as change CSV delimiter and change quoting of CSV fields.

What’s next?

Browserling loves marathons. They will be adding 30 more websites to their network over the next 5 years. Here are some of the other sites they will be launching:

  • Online BROWSER Tools – A collection of browser/web developer tools
  • Online YAML Tools – A collection of Yet Another Markup Language tools
  • Online TSV Tools – A collection of Tab Separated Values tools
  • Online IMAGE Tools – A collection of image editing tools
  • Online AUDIO Tools – A collection of audio editing tools
  • Online PDF Tools – A collection of PDF editing tools
  • Online CRYPTO Tools – A collection of cryptography tools
  • Online RANDOM Tools – A collection of randomization tools
  • Online FILE Tools – A collection of file editing tools
  • Online TIME Tools – A collection of various time and date tools
  • Online LIST Tools – A collection of tools for working with data lists
  • Online CSS Tools – A collection of CSS tools
  • Online JS Tools – A collection of JavaScript tools
  • … and more websites!

If you found these tools useful, please follow Browserling on Twitter and follow Browserling on Facebook.

Obfuscation? Gesundheit!

11 Comments »

If you are a .NET developer, how would you feel if your original C# or VB source code was published on the Web for the world to see? That’s exactly what happens if you release your .NET software without obfuscation.

Read the rest of this entry »

.NET Magazines Compared

2 Comments »

Developers for the Microsoft .NET platform are blessed to have three high-quality .NET magazines available to them: CoDe Component Developer Magazine, MSDN Magazine, and Visual Studio Magazine.

Why would a tech savvy software developer want to read a paper magazine when so much information is available online? Well, some of us “old timers” still appreciate the fresh smell and slick feel of a high-gloss monthly. Also, magazine articles are often produced by professional writers who explain subjects in greater clarity and detail than one may find on the Web. And there are times when a developer may not be connected, such as when riding the train, sitting in a meeting, or eating lunch.

Read the rest of this entry »