Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Programming Articles - Page 2273 of 3366
365 Views
To check if two ArrayList objects are equal, the code is as follows −Example Live Demousing System; using System.Collections; public class Demo { public static void Main(String[] args){ ArrayList list1 = new ArrayList(); list1.Add("A"); list1.Add("B"); list1.Add("C"); list1.Add("D"); list1.Add("E"); list1.Add("F"); list1.Add("G"); list1.Add("H"); list1.Add("I"); Console.WriteLine("Elements in ArrayList1..."); foreach (string res in list1){ Console.WriteLine(res); } ArrayList list2 ... Read More
139 Views
To get a collection of values in the StringDictionary, the code is as follows −Example Live Demousing System; using System.Collections; using System.Collections.Specialized; public class Demo { public static void Main(){ StringDictionary strDict1 = new StringDictionary(); strDict1.Add("S", "Home Appliances"); strDict1.Add("T", "Smart Wearable Tech"); strDict1.Add("U", "Electronics"); strDict1.Add("V", "Toys"); strDict1.Add("W", "Books"); strDict1.Add("X", "Accessories"); Console.WriteLine("StringDictionary elements..."); foreach(DictionaryEntry d in strDict1){ Console.WriteLine(d.Key + " " + d.Value); } ... Read More
136 Views
To check if a SortedList object has a fixed size, the code is as follows −Example Live Demousing System; using System.Collections; public class Demo { public static void Main(){ SortedList list = new SortedList(); list.Add("1", "One"); list.Add("2", "Two"); list.Add("3", "Three"); list.Add("4", "Four"); list.Add("5", "Five"); list.Add("6", "Six"); list.Add("7", "Seven"); list.Add("8", "Eight"); Console.WriteLine("Key and Value of SortedList...."); foreach(DictionaryEntry k in list ) Console.WriteLine("Key: {0}, Value: {1}", ... Read More
281 Views
The BitConverter.ToInt64() method in C# is used to return a 64-bit signed integer converted from eight bytes at a specified position in a byte array.SyntaxThe syntax is as follows −public static long ToInt64 (byte[] val, int begnIndex);Above, val is the byte array, whereas begnIndex is the beginning position within val.Let us now see an example −Example Live Demousing System; public class Demo { public static void Main() { byte[] arr = { 0, 10, 15, 20, 26, 30, 34, 42, 50}; Console.WriteLine("Byte Array = {0} ", BitConverter.ToString(arr)); for (int i = ... Read More
83 Views
The SByte.Equals() method in C# is used to return a value indicating whether this instance is equal to a specified object or SByte.SyntaxThe syntax is as follows −public bool Equals (sbyte ob); public override bool Equals (object ob);Above, the ob parameter for an SByte value to compare to this instance, whereas the ob parameter for the 2nd syntax is an object to compare with this instance.ExampleLet us now see an example − Live Demousing System; public class Demo { public static void Main() { sbyte s1 = 10; sbyte s2 = 100; ... Read More
733 Views
The Stack.Push() method in C# is used to insert an object at the top of the Stack.SyntaxThe syntax is as follows −public virtual void Push (object ob);Above, the parameter ob is the object to push onto the stack.ExampleLet us now see an example − Live Demousing System; using System.Collections; public class Demo { public static void Main() { Stack stack = new Stack(); stack.Push(150); stack.Push(300); stack.Push(500); stack.Push(750); stack.Push(1000); stack.Push(1250); stack.Push(1500); stack.Push(2000); ... Read More
98 Views
The Single.IsNegative() method in C# returns a value indicating whether the specified number evaluates to negative infinity.SyntaxThe syntax is as follows −public static bool IsNegativeInfinity (float val);Above, the parameter val is a single-precision floating-point number.ExampleLet us now see an example − Live Demousing System; public class Demo { public static void Main() { float f1 = 5.0f/0.0f; float f2 = 0.0f/0.0f; Console.WriteLine("Value1 = "+f1); Console.WriteLine("Hashcode for Value1 = "+f1.GetHashCode()); Console.WriteLine("TypeCode for Value1 = "+f1.GetTypeCode()); Console.WriteLine("Is Value1 value is positive or negative infinity? ... Read More
82 Views
The SByte.CompareTo() method in C# is used to compare this instance to a specified object or SByte and returns an indication of their relative values.SyntaxThe syntax is as follows −public int CompareTo (sbyte val); public int CompareTo (object ob);Above, the parameter val is an 8-bit signed integer to compare, whereas ob for the 2nd syntax is an object to compare.ExampleLet us now see an example − Live Demousing System; public class Demo { public static void Main() { sbyte s1 = 55; sbyte s2 = 55; Console.WriteLine("Value of S1 = "+s1); ... Read More
1K+ Views
The Stack.ToString() method in C# is used to get the string representation of the Stack class object.SyntaxThe syntax is as follows −public string ToString ();ExampleLet us now see an example − Live Demousing System; using System.Collections; public class Demo { public static void Main() { Stack stack = new Stack(); stack.Push(150); stack.Push(300); stack.Push(500); stack.Push(750); stack.Push(1000); stack.Push(1250); stack.Push(1500); stack.Push(2000); stack.Push(2500); Console.WriteLine("Stack elements..."); foreach(int val in ... Read More
303 Views
The Stack.ToArray() method in C# is used to copy the Stack to a new array.SyntaxThe syntax is as follows −public virtual object[] ToArray ();ExampleLet us now see an example − Live Demousing System; using System.Collections; public class Demo { public static void Main() { Stack stack = new Stack(); stack.Push("Inspiron"); stack.Push("Alienware"); stack.Push("Projectors"); stack.Push("Monitors"); stack.Push("XPS"); stack.Push("Laptop"); stack.Push("Notebook"); Console.WriteLine("Stack elements..."); foreach(string val in stack) { Console.WriteLine(val); ... Read More