Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# underscore variable

// The underscore before a variable name is a naming convention 
// _val, is used when defining
// the private member variable for a public property.

// Example usage:
private string _val;
public string Values
{
    get { return _val;}
    set {_val = value;}
}
Comment

use of underscore variable

"""Use of _ as a variable
It is to indicate throwaway variables, 
...i.e. variables that are not reused anywhere else (as they are...
        ...not logically important) but for syntax reasons you have to put

This saves space for variables that are actually reused...
...and provides a good mental model for essential and unessential parts...
...of your code

Of course, take this as a guideline. 
There are instances where naming those variables are better for readability...
...especially in group projects

Check out the source for more info!
"""

lst1 = [_ for _ in range(10)]
print(lst1)
# [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
Comment

PREVIOUS NEXT
Code Example
Csharp :: how to add to a list c# 
Csharp :: c# unity 
Csharp :: c# for loop 
Csharp :: c# print list 
Csharp :: visual studio console clear 
Csharp :: ngrok for https 
Csharp :: unity overlapsphere 
Csharp :: how add text to element in javascript 
Csharp :: switch case in c# with multiple values 
Csharp :: process.start web 
Csharp :: parse datetime c# 
Csharp :: how to import datagridview to datatable in c# 
Csharp :: string list to object array in c# 
Csharp :: find genre of song 
Csharp :: how to use navmeshagent in unity 
Csharp :: c# iterate enum 
Csharp :: c# return list in descending order 
Csharp :: how to get specific length of row in matrix c# 
Csharp :: unity print vs debug log 
Csharp :: unity find object by name recursion 
Csharp :: c# do while 
Csharp :: unity interfaces 
Csharp :: array in c# stack overflow 
Csharp :: array of strings by splitting lines c# 
Csharp :: how to restart flutter app programmatically 
Csharp :: c# dictionary with multiple values 
Csharp :: asp.net mvc get current url in view 
Csharp :: c# get custom attribute from property 
Csharp :: Unity gameobject visible to specific camera 
Csharp :: unity rotate around axis 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =