Tag: How to

Java – How to Check if a string is a valid number?

Problem statement You need to check if a input string contain a valid number or not. Solution Use the appropriate wrapper class for converting the string to numeric formats. For example Double to convert string to double as shown below. When the input is a invalid number , the NumberFormatException is caused which needs to be handled by the developers.

How to create a new Windows Phone app to Connect to Mobile Services in Windows Azure?

This article will explain how the developers can create a new windows phone app which connects to the Windows Azure Mobile Services. How to create a new Windows Phone app to Connect to Mobile Services in Windows Azure? 1. Create a Windows Azure Mobile Services as described in the article How to create a new Windows Azure Mobile Service? 2. Select the created mobile service…

How to get the Relative Server Path in ASP.NET Web API ?

In ASP.NET MVC , we can use the Server.MapPath or Request.MapPath to get the relative path of the server for a file. For example , The fileName would be the absolute path of the file. How to get the Relative Server Path in ASP.NET Web API ? You can use the HostingEnvironment.MapPath defined in System.Web.Hosting to get the relative path of the file as shown…

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…

C Program to display half-pyramid using numbers

Problem Write a program in C to print  half-pyramid using numbers as shown.The program should take the number of rows as input. 1 1 2 1 2 3 1 2 3 4 How to create and display half-pyramid pattern in C using numbers? Output Abundantcode.com Coding samples Enter the No. of rows:4 1 1 2 1 2 3 1 2 3 4

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 sort an array using Comparator in Java ?

The Arrays.sort method in java lets the developers to sort an array of objects. The sort method also accepts the comparator object which can contain the sorting logic. How to sort an array using Comparator in Java ? Below is a sample code snippet demonstrating the usage of the Arrays.sort method with the comparator.

Preventing the Orientation from being changed in Windows Phone App

The PhoneApplicationPage has the property Supported Orientation which is used to restrict the orientation of the page in a Windows Phone App. It accepts the values Portrait Landscape PortraitOrLandScape How to Prevent the Orientation from being changed in Windows Phone App? Setting the Supported Orientation to Portrait, Landscape will restrict the orientation from being changed when the windows phone device is rotated. If the Supported…

How to Navigate from One Page to Another in Windows Phone 8 using Hyperlink Button?

Below is a sample code snippet demonstrating how to navigate from a page to another in Windows Phone 8 using Hyperlink Button. How to Navigate from One Page to Another in Windows Phone 8 using Hyperlink Button? Assume that the current page in “MainPage.xaml” and the “ACCode.xaml” is the destination page. One can use the code XAML <HyperlinkButton Content=”GoToAC” NavigateUri=”/ACCode.xaml” HorizontalAlignment=”Left” Margin=”73,292,0,0″ VerticalAlignment=”Top” Height=”57″ Width=”244″…

How to clear the array in JavaScript?

There are times when you want to clear the array that you have already defined with entries and reuse it. For example Arry = [109,625,200]; How to clear the array in JavaScript? One of the easiest way to clear the array contents in JavaScript is setting the Array Length t0 0.

How to perform Shallow Copy in C# ?

To perform Shallow copy in C# , you can use the this.MemberwiseClone() method. How to perform Shallow Copy in C# ? Below is a sample code snippet that contains a method ShallowCopy to make a copy of the object.

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…