Set two arrays.var val = new [] { 20, 40, 60}; var str = new [] { "ele1", "ele2", "ele3"};Use the zip() method to process the two arrays in parallel.var res = val.Zip(str, (n, w) => new { Number = n, Word = w });The above fetches both the arrays with int and string elements respectively.Now, use foreach to iterate the two arrays −Example Live Demousing System; using System.Collections.Generic; using System.Linq; public class Demo { public static void Main() { var val = new [] { 20, 40, 60}; var str = new ... Read More
To fetch the consecutive 1’s, use the Bitwise Left Shift Operator. Here is our decimal number.i = (i & (i
Use Hashset to remove duplicate characters.Here is the string −string myStr = "kkllmmnnoo";Now, use HashSet to map the string to char. This will remove the duplicate characters from a string.var unique = new HashSet(myStr);Let us see the complete example −Example Live Demousing System; using System.Linq; using System.Collections.Generic; namespace Demo { class Program { static void Main(string[] args) { string myStr = "kkllmmnnoo"; Console.WriteLine("Initial String: "+myStr); var unique = new HashSet(myStr); Console.Write("New String after removing duplicates: "); foreach (char c in unique) Console.Write(c); } } }OutputInitial String: kkllmmnnoo New String after removing duplicates: klmno
To validate, you need to check for the protocols.http httpsWith that, you need to check for .com, .in, .org, etc.For this, use the following regular expression −(http|http(s)?://)?([\w-]+\.)+[\w-]+[.com|.in|.org]+(\[\?%&=]*)?The following is the code −Example Live Demousing System; using System.Text.RegularExpressions; namespace RegExApplication { class Program { private static void showMatch(string text, string expr) { Console.WriteLine("The Expression: " + expr); MatchCollection mc = Regex.Matches(text, expr); foreach (Match m in mc) { Console.WriteLine(m); } } ... Read More
The following is our string −string myStr = "5";To check whether the above is a string with numeric representation, use TryParse and out.int.TryParse(myStr, out a);Here is the complete code.Example Live Demousing System.IO; using System; class Program { static void Main() { bool res; int a; string myStr = "5"; // checking for valid string representation of a number res = int.TryParse(myStr, out a); Console.WriteLine(res); } }OutputTrue
Set the string.StringBuilder str = new StringBuilder("Tom Hanks");Now, use the replace() method to replace whitespace with String. Empty. This will eventually remove the whitespace.str.Replace(" ", String.Empty);Let us see the complete code −Example Live Demousing System; using System.Text; class Demo { static void Main() { StringBuilder str = new StringBuilder("Tom Hanks"); Console.WriteLine(str.ToString()); str.Replace(" ", String.Empty); Console.WriteLine(str.ToString()); Console.ReadLine(); } }OutputTom Hanks TomHanks
Declare an array and add elements.int[] val = { 5, 8, 15, 25, 40, 55, 80, 100 };Now, use the Queryable Last() method to get the last element.val.AsQueryable().Last();Let us see the complete code.Example Live Demousing System; using System.Collections.Generic; using System.Linq; class Demo { static void Main() { int[] val = { 5, 8, 15, 25, 40, 55, 80, 100 }; int last_num = val.AsQueryable().Last(); Console.WriteLine("Last element: "+last_num); } }OutputLast element: 100
Many operating systems are not based on one model of the operating system. They may contain multiple operating systems that have different approaches to performance, security, usability needs etc. This is known as a hybrid operating system.The Hybrid operating system may allow one operating system to fulfil one set of requirements and the other operating system to fulfil the rest. For example, one of the operating systems may provide user interface, applications monitoring etc. while the other operating system may be a high-performance operating system that does not provide the same services as the first operating system.Features of Hybrid Operating ... Read More
A command interpreter allows the user to interact with a program using commands in the form of text lines. It was frequently used until the 1970’s. However, in modern times many command interpreters are replaced by graphical user interfaces and menu-driven interfaces.Purpose of Command InterpretersCommand interpreters serve many purposes and are more useful than graphical user interfaces in some cases. Details about these cases are given as follows −Command interpreters have a large range of commands and queries available for different operations. Also, it is much faster to type than to click as is done using graphical user interfaces..There are ... Read More
The standard Java API and virtual machine are mainly designed for desktop as well as server systems. They are not that compatible with mobile devices. Because of this, Google has created a different API and virtual machine for mobile devices. This is known as the Dalvik virtual machine.The Dalvik virtual machine is a key component of the Android runtime and is a part of JVM (Java Virtual Machine) developed specially for Android. The Dalvik virtual machine uses features that are quite important in Java such as memory management, multi-threading etc. The programs in Java are first converted into JVM and ... Read More
 
 Data Structure
 Data Structure Networking
 Networking RDBMS
 RDBMS Operating System
 Operating System Java
 Java MS Excel
 MS Excel iOS
 iOS HTML
 HTML CSS
 CSS Android
 Android Python
 Python C Programming
 C Programming C++
 C++ C#
 C# MongoDB
 MongoDB MySQL
 MySQL Javascript
 Javascript PHP
 PHP 
		 
		 
		 
		