C# variable name __
- C# Variable Name "_" (underscore) only
- C# Hidden Gems - Discards Variable (_)
- C# Naming Conventions
I was just hit with a minor issue in C#, it was just a copy-paste mistake but don't know how C# accept it.
From version 7.0, C# introduced a new feature called discards to create dummy variables, defined by the underscore character _. Discards are equal to unassigned variables. The purpose of this feature is to use this variable when you want to intentionally skip the value by not creating a variable explicitly.
For example - this is when you are calling a method that returns the object but the caller is only interested in calling the method but not in the returned object. In such cases, we can use a discards variable so that it can reduce the memory allocation and make your code clear as well.
C# naming conventions are an important part of C# coding standards and best practice when you are developing a .NET applications. .NET naming conventions are standards how the naming of variables, methods, classes, and other code elements should be defined. In this article, let us learn C# naming conventions.
No comments:
Post a Comment