Tag: How to
C Program to Find the Largest Number from the 3 Input Numbers
Problem Write a program in C language that accepts 3 numbers as inputs and finds the largest among them and displays it on the screen. How find the largest number among the three input numbers in C language ? Output Abundantcode.com Coding samples Enter number1 : 87 Enter number2 : 54 Enter number3 : 23 87 is the largest number.
How to Call Other Constructors within the Same Class in C# ?
There are times when you want to avoid duplicating code and want to reuse them when working on multiple constructors . If you want to call other constructors from a constructor within the same class , you need to use the this keyword . How to Call Other Constructors within the Same Class in C# ? Below is a sample code snippet that demonstrates how…
Displaying all the worksheet names in Excel using VBA Code
Do you want to display the names of the worksheets in the excel workbook ?. Here;s how you can do it using the VBA Code. How to display all the worksheet names in Excel using VBA Code ? Open up the Microsoft Visual Basic for Application Window using the keyboard shortcut key “ALT + F11” and enter the following run and free F5 to run…
How to provide a default value for Auto Implemented Property in C#?
Sometimes, one might want to provide a default value for the auto implemented properties. For example, you might want to provide a default text for a string value instead of null. This can be achieved by providing the default value in the constructor for the properties. Below is a sample code snippet demonstrating how to do it. How to provide a default value for Auto Implemented…
How to Split a String on newlines in C#?
Ever wanted to split an input string in to new lines in .NET (c#) that has a new line character? Below is a sample code snippet that demonstrates how to do it. How to Split a String on newlines in C#?
Example of Predicate Delegate in C#
Predicate Delegate is an interesting feature in .NET Framework which is like a reference to a function which returns either true or false. Example of Predicate Delegate in C# Below is a sample code snippet demonstrating the usage of Predicate Delegate in C#
How to Detect the Current device in Universal App ?
To detect the current device platform in the Windows Universal App , the developers can use the predefined ifdirectives WINDOWS_PHONE_APP and WINDOWS_APP . How to Detect the Current device in Universal App ? Eg : #if WINDOWS_PHONE_APP // wp8.1 #elseif WINDOWS_APP // windows 8.1 #endif
Java – How to Negate a BigDecimal in Java ?
Problem Statement You need to negate the value of the BigDecimal datatype in your java program. Solution Use the negate method defined in the BigDecimal class as shown below. The output of the above program is Abundantcode.com Java Tutorials -10102
How to Download Map in Windows Phone 8 Programatically using C#?
The Windows Phone 8 SDK provides the MapDownloadTask which lets the users to download the region map which can be used for offline usage. This will launch the Map Download App which lets the users to select the map which needs to be downloaded. How to Download Map in Windows Phone 8 Programatically using C#? Below is a sample code snippet demonstrating how the user…
How to set a property value by reflection in C# ?
There are times when you want to set the property of an object using reflection in C#. Below is a sample code snippet demonstrating how to do it taking the Employee class as an example and Name as the property. How to set a property value by reflection in C# ?
Java – How to accept input from Keyboard ?
Problem Statement You need to accpet user input from the keyboard from your java program and display it in the command line. Solution Use the BufferedReader and InputStreamReader defined in the java.io package to read the input data from keyboard and store it in a variable. The output of the above program is Enter data This is a test message from abundantcode.com This is a…
How to Get Connection String from App.config file in C# ?
If you want to get the connection string from the App.config file in C# , you can use the ConfigurationManager class to achieve the same. How to Get Connection String from App.config file in C# ? Assume that the configuration file contains the following Below is the code snippet to get the connection string.
How to Parse a string to Nullable Int in C# ?
Below is a sample code snippet demonstrating how you can convert a string to Nnullable Int in C#. How to Parse a string to Nullable Int in C# ? We use the int.Parse and based on its return value , assign the null or integer value to the Nullable Int.
How to Get the Name of the Anonymous class(type) in C# ?
Below is a sample code snippet which gets the name of the anonymous class . In the below example , the Name and the ID property is set which is anonymous where the type is not specified. When trying to find out the type of the anonymous type , you will get the type as shown in the screenshot below. How to Get the Name…
How to drop a table if it exists in SQL Server 2014 ?
Assume that you want to write a SQL Query in SQL Server which checks if the table exists in database and want to drop it , you can use the OBJECT_ID function to determine the table existence by passing the table name and the ‘U’ as parameters. How to drop a table if it exists in SQL Server 2014 ?
Java – How to setup a Development Environment ?
Problem Statement You need to install java and start developing your first program. Additionally , you also need to download , install and use an IDE (Integrated Development Environment) for development. Solution You need to install Java Development Kit (JDK) 8 which provides the necessary compiler to compile and run your Java programs. Additionally , you can install any one of the following IDE’s by…
Alternate Method to Navigate from Page in Windows Phone 8 using C#
The NavigationService.Navigate method i.e. generally used to navigate from one page to another page in Windows Phone 8 SDK. The NavigationService also exposes a property “Source” which can be used to Get/Set the URI of the page . By Setting this property, the Application Frame loads the specified page. Alternate Method to Navigate from Page in Windows Phone 8 using C# Below is a sample…
How to rename directory from command line in Windows 10 ?
You can rename a directory from command line in Windows 10 using the Rename command. The syntax for renaming the directory is as shown below. Rename <oldname> <newname> How to rename directory from command line in Windows 10 ? Below is an example demonstrating how to change the name of the directory from command prompt. D:\>Rename abundantcode1 abundantcode2 D:\>cd abundantcode2 D:\abundantcode2> The Rename command only…
How to get the first character of a string in SQL Server ?
Assume a scenario where you have a column in your table in SQL Server database where you want to retreive the first character of the column value. How to get the first character of a string in SQL Server ? You can use the LEFT function and specify the column name as well as the number of characters from left that you want to retreive.
Continue statement in Java
The continue statement in java lets the developers to skip the current iteration within the loop statements like for , while or do-while . As soon as the java compiler figures out the continue keyword in the code , it immediately skips the statements that follow the continue keyword and then proceeds with the next iteration. The break statement jumps out of the loop completely…