Tag: How to

How to Rethrow an Exception in C# ?

There are times when you want to handle the exception and then pass it to the higher level . Below is a sample code snippet demonstrating how to Rethrow an exception in C# . How to Rethrow an Exception in C# ?

Alternate Way of getting the Unique DeviceId in Windows Phone 8

The Windows Phone 8 SDK provides the PublisherHostId defined in the HostInformation class which can be used to get the Unique DeviceId in Windows Phone which is specific to the publisher. Alternate Way of getting the Unique DeviceId in Windows Phone 8 Below is a sample code snippet demonstrating how to get the Unique DeviceId in Windows Phone 8 using PublicherHostId. Note that the access…

How to search array elements in Java using Binary Search ?

Do you want to search for an element in a array in Java using Binary Search algorithm ? . If yes , its pretty much easy to do it using the binarySearch method exposed by the Arrays class. How to search array elements in Java using Binary Search ? Below is an example of searching an element using Binary search from array elements in Java.

Using NOT operator to inverse the condition in SQL Server

Imagine a scenario where you want to retreive records that you dont want. You can use the NOT operator to reverse the search condition. For example , You want to get all the departments having the GroupName other than ‘Research and Development’. The other way of getting the same result is using the != in every condition.

How to Download Web Content synchronously in C# ?

If you need to download the web content synchronously using C# , you can use the WebClient class that is defined in the System.Net namespace. Below is a sample code snippet demonstrating how to download web content synchronously in c#. How to Download Web Content synchronously in C# ? The output file is generally saved in the same folder where the exe exists.

C# Program to display "Hello, World!"

Problem Write a program in C# to display “Hello, World!” on the screen. C# Program to display “Hello, World!” in Console Window. This is a simple C# program that displays “Hello, World!” on the console window. Output Hello, World!

How to Generate C# class from a XML file ?

Do you want to generate C# class from an XML file ?. You can use the xsd tool to do it. How to Generate C# class from a XML file ? 1. Just launch the Visual Studio Developer Command prompt from the Windows Start menu. 2. Type the command xsd and specify the path of the xml file. xsd d:\test\test.xml 3. This will create the…

C Program to display Fibonacci Numbers

Problem Write a program in C to display the sequence of Fibonacci numbers of first n numbers entered by the user. How to display Fibonacci sequence in C Language ? Before writing a program to display the Fibonacci sequence , it is important to understand what exactly is the Fibonacci sequence. It is a series where the next number is the sum of the previous…

How to Declare a variable in SQL Server ?

You will most likely declare a variable in the SQL Server and use it in the SQL Statements. You can use the DECLARE statement and specify the variable and datatype and optionally provide a default value. For example , You can declare an NewEmployeeJobTitle variable using the DECLARE statement and provide a default value as ‘Chief Executive Officer’ DECLARE @NewEmployeeJobTitle nvarchar(50) = ‘Chief Executive Officer’;…

How to Get the Path to special folder using C# ?

If you want to get the path to the special of the user like My Documents etc. , you can use the Environment.GetFolder with the enum “Environment.SpecialFolder”. How to Get the Path to special folder using C# ? Below is a sample code snippet demonstrating on how to do it.

How to sort an array in Java ?

If you want to sort an array in Java , you can use the Arrays.sort utility method to do it. How to sort an array in Java ? Below is a sample code snippet demonstrating the usage of the Arrays.sort utility method to sort an array in java.

How to Add Border to the Ellipse Control in Windows Phone 8 ?

Looking for an option to add border with a different color to the Ellipse Control in Windows Phone 8 ? Here’s a simple way to do it. How to Add Border to the Ellipse Control in Windows Phone 8 ? Assume that the Ellipse tag in the XAML is as shown below. The Ellipse has the background color “Chocolate”. <Ellipse Height=”52″ Width=”52″ Fill=”Chocolate”/> We can…

How do take Screenshot in Windows Phone 8 device?

The Windows Phone 8 allows the users to take screenshot of the current screen. This was a feature that was included in Windows Phone 8. How do take Screenshot in Windows Phone 8 device? 1. Hold the Power button and the Windows Key simultaneously. 2. This will take a screenshot on the Windows Phone 8 device which will be stored in the Screenshots album.

How to hide the status bar in Microsoft Excel with the VBA Code?

Do you want to hide the status bar in Microsoft Excel ?. You can use the VBA code to do it quickly. How to hide the status bar in Microsoft Excel with the VBA Code? 1. Open the excel workbook in Microsoft Excel 2016 and press the keyboard shortcut key “Alt + F11” to open the Microsoft Visual Basic for Applications window. 2. Click the…

Java – How to document your code ?

Problem Statement You need to document your java classes so that it helps in maintenance. Solution Use Javadoc and place comments before any method , field or class to document. Just enter /** to start writing the comments using javadoc. The subsequent lines needs to begin with * and end the comment section with */ Below is a sample code demonstrating the usage of the…