Tag: How to

Difference between Hash table and Dictionary in .NET

Here’s a simple difference between Hashtable and Dictionary in .NET Dictionary Hashtable It is generic in nature It is non generic in nature It is defined in the namespace System.Collections.Generic It is defined in the namespace System.Collections When a request is made to the dictionary and if the key does not exists , you get an exception When a request is made to the Hashtable…

C Program to find if the Given year is a Leap Year or Not

Problem Write a program in C to check whether a year entered by the user is a leap year or not. How to find if the given Year is a Leap Year or Not in C ? If the Year is divisible exactly by 4 , then it is a Leap Year. Additionally for the century years that ends with 00 , it is a…

Sorting the Data in a Query in SQL Server

You want the results of the query to be displayed in a sorted order based on some query. In this case , you use the ORDER BY clause in the query by specifying the column on which the sort to work. For example , you want to sort the Departments table in the database by the column DepartmentName. Here’s how the query looks like This…

How to get the IP Address of the Local Machine using C# ?

You can get the IP address of the local machine or localhost using C# using the Dns class’s GetHostByName defined in the System.Net namespace. The Dns.GetHostByName returns the array of AddressList which contains the IP address . How to get the IP Address of the Local Machine using C# ? Below is the sample code snippet demonstrating the retrieval of the IP address of the…

How to create RadioButton in ASP.NET MVC ?

The ASP.NET MVC Framework provides the helper method RadioButton and RadioButtonFor to create radio button in ASP.NET MVC web page. How to create RadioButton in ASP.NET MVC ? Below is a sample sourecode snippet demonstrating how to create RadioButton in ASP.NET MVC . View @model MvcApplication1.Models.EmployeeVM @{ ViewBag.Title = “Index”; } <h2>@ViewBag.ApplicationTitle</h2> @Html.Label(“AbundantCode-a Programming Directory”) @Html.RadioButtonFor(Model => Model.IsActive, true) @Html.RadioButtonFor(Model => Model.IsActive, false)

How to Use SpeechRecognizer in Windows Phone App using C#?

Below is a sample code snippet demonstrating how to use the SpeechRecognizerUI in your Windows Phone app using C#. Note that by default the speech recognizer API uses the default speech grammar accessed via the Microsoft cloud service and hence requires the network connection to be available for the below code snippet to work. How to Use SpeechRecognizer in Windows Phone App using C#? When…

How to get the Number of Elements in an Array in C# ?

You can use the Length property of the array to return the number of elements in it. Note that once the array is created , you cannot change its length. How to get the Number of Elements in an Array in C# ? Here’s a code snippet demonstrating the usage of the Length property of the array to get the number of elements.

Can the Internet Explorer Share Picker be extended in Windows Phone 8 ?

There are times when one might want to implement the sharing of links from the Windows Phone 8 Internet Explorer via the Share Picker. similar to the Photo App Share Picker. Is it possible to extend Internet Explorer’s share picker on Windows Phone 8 ? Unfortunately , No . It is not possible to extend the Share Picker in Windows Phone (IE Mobile) currently.

How to Get the Maximum value from a List of String using LINQ in C# ?

In one of the previous article , we explained how to get the maximum value from a list of integer using LINQ query in C# . What happens when the column is a string instead of integer ?. Below are 2 possibilities on how to get the maximum value from a list of string. How to Get the Maximum value from a List of String…

How to repeat the characters X times in C# ?

You can use the string constructor and pass the character that you wish to be present in it. The string constructor also takes the second parameter to specify the number of times the character to be repeated. How to repeat the characters X times in C# ? Below is a sample code snippet demonstrating how the string constructor can be used to repeat * 4…

How to Get the localhost IP address in Java ?

If you want to get the localhost IP address in java , you can use the InetAddress class which exposes the getLocalHost method and later use the getHostAddress method of the InetAddress. The getLocalHost method returns the host information of type InetAddress . The InetAddress type has the method getHostAddress which returns the IP address. How to Get the localhost IP address in Java ?…

How to sort an array in C# ?

If you want to sort an array in C#.NET , you can use the Array.Sort method to do it. How to sort an array in C# ? Below is a sample code snippet demonstrating the usage of the Array.Sort method to sort an array in C#.

How to Convert a List to ObservableCollection in C#?

This simple blog post will explain how to convert a List of Object to ObservableCollection of Object in C# and Windows Phone 8. There are times when you want to convert a List of Object to ObservableCollection specially when binding an ObservableCollection to the LongListSelector etc. The reasons for this can be several. How to Convert a List to ObservableCollection in C#? To Convert a…