Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Articles on Trending Technologies
Technical articles with clear explanations and examples
Time Functions in C#
The DateTime has methods and properties for Date and Time as well like how to get the number of hours or minutes of a day, etc.Let us only focus on the time functions −Refer MSDN (Microsoft Developer Network) for all the functions −Sr.No.Method & Properties1AddDays(Double)Returns a new DateTime that adds the specified number of days to the value of this instance.2AddHours(Double)Returns a new DateTime that adds the specified number of hours to the value of this instance.3AddMilliseconds(Double)Returns a new DateTime that adds the specified number of milliseconds to the value of this instance.4AddMinutes(Double)Returns a new DateTime that adds the specified ...
Read MoreUse dropdowns with any button size using Bootstrap
Use btn-large, .btn-sm, or .btn-xs class to use dropdowns with any button size.Let us see an example of btn-largeExample Bootstrap Example Default Action Another action Something else here Separated link
Read MoreSet important information for a list item in a list group with Bootstrap
use the list-group-item-info class in Bootstrap to set key information for a list item in a list group.You can try to run the following code to implement the list-group-item-info class −Example Bootstrap Example Java Interfaces Multi-threading Packages
Read MoreHow to display Absolute value of a number in C#?
To find the absolute value of a number in C#, use the Math.Abs method.Set numbers first −int val1 = 77; int val2 = -88;Now take two new variables and get the Absolute value of the above two numbers −int abs1 = Math.Abs(val1); int abs2 = Math.Abs(val2);Let us see the complete code to display Absolute value of a number −Exampleusing System; class Program { static void Main() { int val1 = 77; int val2 = -88; Console.WriteLine("Before..."); Console.WriteLine(val1); Console.WriteLine(val2); int ...
Read MoreC# program to remove all duplicates words from a given sentence
Set a string with duplicate words.string str = "One Two Three One";Above, you can see the word “One” comes twice.To remove dulicate words, you can try to run the following code in C# −Exampleusing System; using System.Linq; public class Program { public static void Main() { string str = "One Two Three One"; string[] arr = str.Split(' '); Console.WriteLine(str); var a = from k in arr orderby k select k; Console.WriteLine("After removing duplicate words..."); ...
Read MoreScope of Variables in C#
The scope of a variable is a region of code that indicates where the variables are being accessed.For a variable, it has the following levels −Method LevelVariable declared inside a method is a local variable.Class LevelVariable declared inside a class is a local variable are class member variables.Let us see an example of scope of variables −Exampleusing System; namespace Demo { class Program { public int Divide(int num1, int num2) { // local variable in a method int result; result = num1 / ...
Read MoreNest button groups with Bootstrap
Nest button groups within another button group i.e, place a .btn-group within another .btn-group. This is done when you want dropdown menus mixed with a series of buttons.To nest button groups, you can try to run the following code −Example Bootstrap Example Rank Marks Subjects Maths Science English
Read MoreMap function and Lambda expression in Python to replace characters
We want to replace a character a1 with a character a2 and a2 with a1. For example, For the input string, "puporials toinp"and characters p and t, we want the end string to look like −"tutorials point"For this we can use map function and lambdas to make the replacement. The map(lambda, input) function iterates over each item passed to it(in form of iterable input) and apply the lambda expression to it. So we can use it as follows −Exampledef replaceUsingMapAndLambda(sent, a1, a2): # We create a lambda that only works if we input a1 or a2 and swaps them. newSent ...
Read MoreC# Program to replace a special character from a String
Let’s say our string is −string str = "abcd$ef$gh";To replace the special character, use the Replace() method.string res = str.Replace('$', 'k');The following is the complete code to replace character from a string −Exampleusing System; public class Program { public static void Main() { string str = "abcd$ef$gh"; Console.WriteLine("Initial string = " + str); string res = str.Replace('$', 'k'); // after replacing Console.WriteLine("Replaced string = " + res.ToString()); } }OutputInitial string = abcd$ef$gh Replaced string = abcdkefkgh
Read MoreHow to clear screen using C#?
Use the Console.Clear() method to clear screen and the console buffer. When the Clear method is called, the cursor automatically scrolls to the top-left corner of the window.Here, we have cleared the screen and then set the ForegroundColor and BackgroundColor −ConsoleColor newForeColor = ConsoleColor.Blue; ConsoleColor newBackColor = ConsoleColor.Yellow;The following is the complete code −Exampleusing System; using System.Collections.Generic; class Program { static void Main() { ConsoleColor foreColor = Console.ForegroundColor; ConsoleColor backColor = Console.BackgroundColor; Console.WriteLine("Clearing the screen!"); Console.Clear(); ConsoleColor newForeColor = ConsoleColor.Blue; ConsoleColor newBackColor = ConsoleColor.Yellow; } }OutputClearing the screen!
Read More