Tag: tricks

Auto-Property Initializers with Method Call in C# 6.0

The Auto-Property Initializer in C# 6.0 is a feature that lets the users to initialize the value of the auto implemented property . This feature lets the user provide any expression (lambda expression or a method) . Auto-Property Initializers with Method Call in C# 6.0 The below code snippet demonstrates how to initialize the auto property with a method call.

How to Turnoff Frame rate counter in UWP App ?

You can turn off the frame rate counter in your Universal Windows Platform (UAP) apps by following the below steps. How to Turnoff Frame rate counter in UWP App ? 1. Open your UWP project built using C# and XAML in Visual Studio. 2. From Visual Studio Solution explorer , open App.xaml.cs. 3. Set the DebugSettings.EnableFrameRateCounter property with the false false. as shown below.

How to remove the non ascii characters from a string in C# ?

Regular expression comes in handy especially if you want to remove the non ascii characters from a string in C#. Here’s a regular expression sample in C# demonstrating how to do it. How to remove the non ascii characters from a string in C# ? The output of the code snippet will be cde in C#

Column Alias in SQL Query

When returning the query results , you want to provide an alternate name for the column for readability purpose , you can use the AS clause to specify the column alias in SQL Query. How to specify Column alias in SQL Query ? Below is an example of the usage of the column alias in SQL Query. Every column in the Query result has a…

Exit the Current Scope with a return value in SQL Server

You can use the RETURN statement to discontinue the execution of a T-SQL batch statement or a stored procedure and provide a status code or value on return. For example , you want to display the Employees whose MaritalStatus is Divorced. You want to return a value -1 to indicate that no records exist and also You do not want the SQL Statements following it…

How to add new user account from command line in Windows 10 ?

You can add a new user account in Windows 10 using command prompt using the net user command and passing the right parameter. How to add new user account from command line in Windows 10 ? Following is the syntax of the command to add a new user from command line in Windows. net user <username> <password> /ADD For example , to add a new…

How to convert number to text in Excel?

In Microsoft Excel 2016 , there are times when you don’t want the numbers present in the cell to be participating in the calculation. This means , you can either update the formula to not include the cell value or else change the number to text. How to convert number to text in Microsoft Excel 2016? You can use the TEXT function in Excel to…

How to Detect Windows Phone OS version using C#?

The Windows Phone SDK provides the Environment.OSVersion property which can be used to detect the version of the Operating System uses in Windows Phone (Windows Phone 8 / Windows Phone 7). Below is a code snippet that demonstrates how to detect the Windows Phone OS Version using C#. How to Detect Windows Phone OS version using C#?

How to Check if all elements in array are alphabets in JavaScript ?

JavaScript provides the every() method defined in the Array object which lets the developers to check and validate the contents of the array in JavaScript. How to Check if all elements in array are alphabets in JavaScript ? Below is a sample code snippet demonstrating the usage of the every() method to find out if all the elements in the array are alphabets. Note that…

How to change the ‘Edit Top 200 Rows’ in SQL Management Studio ?

When working with the SQL Server Management Studio and trying to edit the table records , you would have noticed the context menu option “Edit Top 200 Rows”. How do you change this to display all the records for editing instead of “Edit top 200 rows” in the context menu ? There are couple of ways in which you can do it. 1. Right click…

How to change Language Version from C# 6.0 in Visual Studio 2015 ?

There are times when you are developing .NET Project in Visual Studio 2015 with C# 6.0 enabled and you might also have members in your team using Visual Studio 2013 and still want to build and run the project. How to change Language Version from C# 6.0 in Visual Studio 2015 ? You can change the C# language version from the project properties. In the…

DateTime and Null value in C#

Assume that you want a variable of type DateTime and you would like to have the uninitialized value or null value , you can use the nullable DateTime type. DateTime and Null value in C# When you define a DateTime variable and dont initialize it , the default value is the DateTime.MinValue. You can simply define the type as Nullable DateTime as shown in the…

How to shutdown or reboot Windows machine from command line in Windows 10 ?

You can reboot a windows machine or shutdown it from the command line in Windows 10 using some of the built-in commands. How to shutdown or reboot Windows machine from command line in Windows 10 ? To shutdown the windows machine , we can use the following command. shutdown /s Similarly , you can reboot or restart the windows machine using the following command shutdown…