How to check if a variable exists in Python

To check if a variable exists in Python, you can use the snippet below.

Sample Python

if 'myVariable' in locals(): # myVariable exists locally.
if 'myVariable' in globals(): # myVariable exists globally.

Please rate this snippet

What is the best datatype for money in C# and VB.NET

The best Datatype for money in C# and VB.NET is Decimal.
What is the MSDN saying about Decimal.

The Decimal value type represents decimal numbers ranging from positive 79,228,162,514,264,337,593,543,950,335 to negative 79,228,162,514,264,337,593,543,950,335. The Decimal value type is appropriate for financial calculations requiring large numbers of significant integral and fractional digits and no round-off errors. The Decimal type does not eliminate the need for rounding. Rather, it minimizes errors due to rounding.

MSDN SOURCE

Please rate this snippet

How to use DebuggerDisplayAttribute in C# and VB.NET

If you want to change the information, the debugger variable window shows for your class, you can use the DebuggerDisplayAttribute.
Simply put the Attribut above your class declaration. The Value between {} are the name of the property or Field you want to show.

Sample C#

[DebuggerDisplay("Name = {Name}, Value = {Value}")]

Sample VB.NET

<DebuggerDisplay("Name = {Name}, Value = {Value}")>

Result

DebuggerDisplayAttribute

for more informations see the DebuggerDisplayAttribute Class MSDN Entry

Please rate this snippet