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
Programming Articles
Page 605 of 2544
Check whether the specified Unicode character is a punctuation mark in C#
To check whether the specified Unicode character is a punctuation mark, the code is as follow −Exampleusing System; public class Demo { public static void Main() { bool res; char val = 'q'; Console.WriteLine("Value = "+val); res = Char.IsPunctuation(val); Console.WriteLine("Is the value a punctuation? = "+res); } }OutputThis will produce the following output −Value = q Is the value a punctuation? = FalseExampleLet us see another example −using System; public class Demo { public static void Main() { bool ...
Read MoreFind missing number in another array which is shuffled copy in C++
Suppose, we have two arrays A and B, the array A has n elements. The second array B has all the elements of A, but they are shuffled and one element is removed. We have to find the missing elements. So if A = [4, 8, 1, 3, 7], and B = [7, 4, 3, 1], the output is 8.This can be solved using XOR trick. The combined occurrence of each element is twice, one in A, and other in B, except one element which only has a single occurrence in A. As we know that x XOR x = ...
Read MoreFind set of m-elements with difference of any two elements is divisible by k in C++
Suppose we have an array with N positive integers, and another variable K. We have to find the exactly m-elements, such that difference between any two elements is equal to k. So if the array is A = [4, 7, 10, 6, 9], and k = 3 and m = 3, then output will be “yes”. As we can find three elements like 4, 7, 10.To solve this, we have to keep track of the remainders, when an element is divided by k. Now create a multi-dimensional array rem[][] of size k, its index is showing the remainder, and elements ...
Read MoreHow to remove element from the specified index of the List in C#?
To remove the element from the specified index of the List, the code is as follows −Exampleusing System; using System.Collections.Generic; public class Demo { public static void Main(String[] args){ List list = new List(); list.Add("Ryan"); list.Add("Kevin"); list.Add("Andre"); list.Add("Tom"); list.Add("Fred"); list.Add("Jason"); list.Add("Jacob"); list.Add("David"); Console.WriteLine("Count of elements in the List = "+list.Count); Console.WriteLine("Enumerator iterates through the list elements..."); List.Enumerator demoEnum = list.GetEnumerator(); ...
Read MoreHow to get Synchronize access to an Array in C#?
To get synchronize access to an array, the code is as follows −Exampleusing System; public class Demo { public static void Main() { Array intArr = new int[] {5, 10, 15, 20, 25, 30, 35, 40 }; Console.WriteLine("Integer array..."); foreach (int i in intArr) Console.WriteLine(i); Console.WriteLine("After applying lock on array..."); lock(intArr.SyncRoot) { foreach (Object ob in intArr) Console.WriteLine(ob); } } }OutputThis will produce the following output −Integer array... 5 10 ...
Read MoreFind foot of perpendicular from a point in 2D plane to a Line in C++
Consider we have a point P in 2D plane and equation of a line, the task is to find the foot of the perpendicular from P to the line.The equation of the straight line is ax + by + c = 0. Equation of line passing through P and perpendicular to line. Equation of line passing through P and Q will be ay – bx + d = 0. Also P(x1, y1), and Q(x2, y2), so we put coordinate of P on the equation.ay 1−bx 1+d=0, so d=bx1−ay 1Also Q is the intersection of the given line and the line ...
Read MoreHow to get Seventh Element of the Tuple in C#?
To get seventh element of the Tuple, the code is as follows −Exampleusing System; public class Demo { public static void Main(String[] args) { var tuple1 = Tuple.Create(75, 200, 500, 700, 100, 1200, 1500); var tuple2 = Tuple.Create(75, 200, 500, 700, 100, 1200, 1500); Console.WriteLine("Is Tuple1 equal to Tuple2? = "+tuple1.Equals(tuple2)); Console.WriteLine("HashCode of Tuple1 = "+tuple1.GetHashCode()); Console.WriteLine("HashCode of Tuple2 = "+tuple2.GetHashCode()); Console.WriteLine("Tuple1 Item 1st = "+tuple1.Item1); Console.WriteLine("Tuple2 Item 1st = "+tuple2.Item1); Console.WriteLine("Tuple1 Item 2nd = ...
Read MoreHow to retrieve the system’s reference to the specified String in C#?
To retrieve the system’s reference to the specified String, the code is as follows −Exampleusing System; public class Demo{ public static void Main(string[] args){ string str1 = "David"; string str2 = string.Intern(str1); Console.WriteLine("String1 = "+str1); Console.WriteLine("System reference of String1 = "+str2); } }OutputThis will produce the following output −String1 = David System reference of String1 = DavidExampleLet us now see another example −using System; public class Demo{ public static void Main(string[] args){ string str1 = "50"; string str2 ...
Read MoreRemove from the specified index of the StringCollection in C#
To remove from the specified index of the StringCollection, the code is as follows −Exampleusing System; using System.Collections.Specialized; public class Demo { public static void Main() { StringCollection stringCol = new StringCollection(); String[] arr = new String[] { "100", "200", "300", "400", "500" }; Console.WriteLine("Array elements..."); foreach (string res in arr) { Console.WriteLine(res); } stringCol.AddRange(arr); Console.WriteLine("Total number of elements = "+stringCol.Count); stringCol.RemoveAt(3); Console.WriteLine("Total number of elements now ...
Read MoreHybridDictionary Class in C#?
The HybridDictionary class implements IDictionary by using a ListDictionary while the collection is small, and then switching to a Hashtable when the collection gets large.Following are the properties of the HybridDictionary class −Sr.NoProperty & Description1CountGets the number of key/value pairs contained in the HybridDictionary.2IsFixedSizeGets a value indicating whether the HybridDictionary has a fixed size.3IsReadOnlyGets a value indicating whether the HybridDictionary is read-only.4IsSynchronizedGets a value indicating whether the HybridDictionary is synchronized (thread safe).5Item[Object]Gets or sets the value associated with the specified key.6KeysGets an ICollection containing the keys in the HybridDictionary.7SyncRootGets an object that can be used to synchronize access to the ...
Read More