Returns a string that represents the unqualified name of a variable, type, or member.
int counter = 10;
nameof(counter); // Returns "counter"
Client client = new Client();
nameof(client.Address.PostalCode)); // Returns "PostalCode"
The nameof operator was introduced in C# ...
compile built-in function can be used to precompile an expression to a code object; this code object can then be passed to eval. This will speed up the repeated executions of the evaluated code. The 3rd parameter to compile needs to be the string 'eval'.
>>> code = compile('a * b + c', '&l...
>>> variables = {'a': 6, 'b': 7}
>>> eval('a * b', globals=variables)
42
As a plus, with this the code cannot accidentally refer to the names defined outside:
>>> eval('variables')
{'a': 6, 'b': 7}
>>> eval('variables', globals=variables)
Traceback (most ...
You can fetch the current properties of the Annotation by using Reflection to fetch the Method or Field or Class which has an Annotation applied to it, and then fetching the desired properties.
@Retention(RetentionPolicy.RUNTIME)
@interface MyAnnotation {
String key() default "foo";...
As the static keyword is used for accessing fields and methods without an instantiated class, it can be used to declare constants for use in other classes. These variables will remain constant across every instantiation of the class. By convention, static variables are always ALL_CAPS and use unders...
Static gives a method or variable storage that is not allocated for each instance of the class. Rather, the static variable is shared among all class members. Incidentally, trying to treat the static variable like a member of the class instance will result in a warning:
public class Apple {
pu...
It is possible to create a QtQuick view directly from C++ and to expose to QML C++ defined properties. In the code below the C++ program creates a QtQuick view and exposes to QML the height and width of the view as properties.
main.cpp
#include <QApplication>
#include <QQmlContext>
#...
The Application directive defines application-specific attributes. It is provided at the top of the global.aspx file.
The basic syntax of Application directive is:
<%@ Application Language="C#" %>
The attributes of the Application directive are:
AttributesDescriptionInheritsThe...
The control directive is used with the user controls and appears in the user control (.ascx) files.
The basic syntax of Control directive is:
<%@ Control Language="C#" EnableViewState="false" %>
The attributes of the Control directive are:
AttributesDescriptionAutoEv...
The Implement directive indicates that the web page, master page or user control page must implement the specified .Net framework interface.
The basic syntax for implements directive is:
<%@ Implements Interface="interface_name" %>
This example show how you can check if a service already exists (i.e., is installed on the machine) or not. This code requires only the lowest privileges necessary, so each process can perform the check, no matter what level of security it is running at.
#define UNICODE
#define _UNICODE
#include ...
>>> '{0:.0f}'.format(42.12345)
'42'
>>> '{0:.1f}'.format(42.12345)
'42.1'
>>> '{0:.3f}'.format(42.12345)
'42.123'
>>> '{0:.5f}'.format(42.12345)
'42.12345'
>>> '{0:.7f}'.format(42.12345)
'42.1234500'
Same hold for other way of referenc...
You can also use regular expressions to split a string. For example,
import re
data = re.split(r'\s+', 'James 94 Samantha 417 Scarlett 74')
print( data )
# Output: ['James', '94', 'Samantha', '417', 'Scarlett', '74']
You can get rid of manage.py and use the django-admin command instead. To do so, you will have to manually do what manage.py does:
Add your project path to your PYTHONPATH
Set the DJANGO_SETTINGS_MODULE
export PYTHONPATH="/home/me/path/to/your_project"
export DJANGO_SETTINGS_MODULE...
IList<T> is never a subtype of a different IList<T1>. IList is invariant in its type parameter.
class Animal { /* ... */ }
class Dog : Animal { /* ... */ }
IList<Dog> dogs = new List<Dog>();
IList<Animal> animals = dogs; // type error
There is no subtype relat...
If you have a vsix file, you can install it by running the file.
Get the vsix file (this is the extension installer)
Run the file.
In the window that opens, confirm the installation.
In Visual studio
go to Tools > Extensions and updates...
In the window that opens go to online
Select Visual Studio Gallery
You can search for an extension on the search box at the upper right corner
Select the extension you want to add
Click on download.
Once download is complete, click...
int x = 5 / 0; // Undefined behavior
Division by 0 is mathematically undefined, and as such it makes sense that this is undefined behavior.
However:
float x = 5.0f / 0.0f; // x is +infinity
Most implementation implement IEEE-754, which defines floating point division by zero to return N...