Articles on Trending Technologies

Technical articles with clear explanations and examples

The ? : Operator in Perl

Mohd Mohtashim
Mohd Mohtashim
Updated on 11-Mar-2026 532 Views

Let's check the conditional operator? : in Perl which can be used to replace if...else statements. It has the following general form −SyntaxExp1 ? Exp2 : Exp3;Where Exp1, Exp2, and Exp3 are expressions. Notice the use and placement of the colon.The value of a? expression is determined like this: Exp1 is evaluated. If it is true, then Exp2 is evaluated and becomes the value of the entire? expression. If Exp1 is false, then Exp3 is evaluated and its value becomes the value of the expression. Below is a simple example making use of this operator −Example#!/usr/local/bin/perl $name = "Ali"; $age ...

Read More

Removing all entries from the StringDictionary in C#

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 121 Views

To remove all entries from the StringDictionary, the code is as follows −Exampleusing System; using System.Collections; using System.Collections.Specialized; public class Demo {    public static void Main(){       StringDictionary strDict1 = new StringDictionary();       strDict1.Add("A", "John");       strDict1.Add("B", "Andy");       strDict1.Add("C", "Tim");       strDict1.Add("D", "Ryan");       strDict1.Add("E", "Kevin");       strDict1.Add("F", "Katie");       strDict1.Add("G", "Brad");       Console.WriteLine("StringDictionary1 elements...");       foreach(DictionaryEntry d in strDict1){          Console.WriteLine(d.Key + " " + d.Value);       }       Console.WriteLine("Does ...

Read More

Removing all nodes from LinkedList in C#

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 237 Views

To remove all nodes from LinkedList, the code is as follows −Exampleusing System; using System.Collections.Generic; public class Demo {    public static void Main() {       int [] num = {10, 20, 30, 40, 50};       LinkedList list = new LinkedList(num);       Console.WriteLine("LinkedList nodes...");       foreach (var n in list) {          Console.WriteLine(n);       }       list.Clear();       Console.WriteLine("LinkedList is empty now!");       foreach (var n in list) {          Console.WriteLine(n);       }    } }OutputThis ...

Read More

Get an enumerator that iterates through StringCollection in C#

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 189 Views

To get an enumerator that iterates through 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("Does the specified string is in the StringCollection? = "+stringCol.Contains("800"));       Console.WriteLine("Total number of elements = "+stringCol.Count);       ...

Read More

Get or set the element at the specified index in ArrayList in C#

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 1K+ Views

To get or set the element at the specified index in ArrayList, the code is as follows −Exampleusing System; using System.Collections; public class Demo {    public static void Main() {       ArrayList arrList = new ArrayList();       arrList.Add("Laptop");       arrList.Add("Desktop");       arrList.Add("Notebook");       arrList.Add("Ultrabook");       arrList.Add("Tablet");       arrList.Add("Headphone");       arrList.Add("Speaker");       Console.WriteLine("Elements in ArrayList...");       foreach(string str in arrList) {          Console.WriteLine(str);       }       Console.WriteLine("Element at index 5 = " + ...

Read More

Get an enumerator that iterates through the Dictionary in C#

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 578 Views

To get an enumerator that iterates through the Dictionary, the code is as follows −Exampleusing System; using System.Collections; using System.Collections.Generic; public class Demo {    public static void Main(){       Dictionary dict = new Dictionary();       dict.Add(100, "Laptop");       dict.Add(150, "Desktop");       dict.Add(200, "Earphone");       dict.Add(300, "Tablet");       dict.Add(500, "Speakers");       dict.Add(750, "HardDisk");       dict.Add(1000, "SSD");       IDictionaryEnumerator demoEnum = dict.GetEnumerator();       Console.WriteLine("Enumerator iterating key-value pairs...");       while (demoEnum.MoveNext())       Console.WriteLine("Key = " + demoEnum.Key + ...

Read More

Check if an array is read-only or not in C#

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 286 Views

To check if an array is read-only or not, try the below code −Exampleusing System; public class Demo {    public static void Main(){       string[] products = new string[] { };       Console.WriteLine("One or more planets begin with 'E'? = {0}",          Array.Exists(products, ele => ele.StartsWith("E")));       Console.WriteLine("Is the array having fixed size? = " + products.IsFixedSize);       Console.WriteLine("Is the array read only? = " + products.IsReadOnly);    } }OutputThis will produce the following code −One or more planets begin with 'E'? = False Is the array having ...

Read More

Bitwise OR operation between the elements of BitArray in C#

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 115 Views

Let us see how to implement Bitwise OR operation between the elements of BitArray −Exampleusing System; using System.Collections; public class Demo {    public static void Main() {       BitArray arr1 = new BitArray(5);       BitArray arr2 = new BitArray(5);       arr1[0] = false;       arr1[1] = false;       arr2[0] = false;       arr2[1] = true;       Console.WriteLine("BitArray1 elements...");       foreach (bool res in arr1) {          Console.WriteLine(res);       }       Console.WriteLine("BitArray2 elements...");       foreach ...

Read More

Check if a HashSet contains the specified element in C#

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 876 Views

To check if a HashSet contains the specified element, the code is as follows −Exampleusing System; using System.Collections.Generic; public class Demo {    public static void Main(){       HashSet set1 = new HashSet();       set1.Add(25);       set1.Add(50);       set1.Add(75);       set1.Add(100);       set1.Add(125);       set1.Add(150);       Console.WriteLine("Elements in HashSet1");       foreach(int val in set1){          Console.WriteLine(val);       }       HashSet set2 = new HashSet();       set2.Add(30);       set2.Add(60);       ...

Read More

Check if a HashSet is a proper subset of the specified collection in C#

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 172 Views

To check if a HashSet is a proper subset of the specified collection, try the following code −Exampleusing System; using System.Collections.Generic; public class Demo {    public static void Main(){       HashSet set1 = new HashSet();       set1.Add(70);       set1.Add(100);       set1.Add(125);       set1.Add(150);       Console.WriteLine("Elements in HashSet1");       foreach(int val in set1){          Console.WriteLine(val);       }       HashSet set2 = new HashSet();       set2.Add(30);       set2.Add(60);       set2.Add(70);       set2.Add(80); ...

Read More
Showing 7551–7560 of 61,248 articles
« Prev 1 754 755 756 757 758 6125 Next »
Advertisements