Queue Contains Method in C#

AmitDiwan
Updated on 03-Dec-2019 13:19:23

225 Views

The Queue.Contains() method in C# is used to determine whether an element is in the Queue.SyntaxThe syntax is as follows -public virtual bool Contains (object ob);Above, the parameter ob is the Object to locate in the Queue.ExampleLet us now see an example - Live Demousing System; using System.Collections.Generic; public class Demo {    public static void Main() {       Queue queue = new Queue();       queue.Enqueue("Gary");       queue.Enqueue("Jack");       queue.Enqueue("Ryan");       queue.Enqueue("Kevin");       queue.Enqueue("Mark");       queue.Enqueue("Jack");       queue.Enqueue("Ryan");       queue.Enqueue("Kevin");       Console.Write("Count ... Read More

StringBuilder CopyTo Method in C#

AmitDiwan
Updated on 03-Dec-2019 13:10:16

334 Views

The StringBuilder.CopyTo() method in C# is used to copy the characters from a specified segment of this instance to a specified segment of a destination Char array.SyntaxThe syntax is as follows -public void CopyTo (int sourceIndex, char[] dest, int destIndex, int count);Above, the parameter sourceIndex is the starting position in this instance where characters will be copied from. The dest is the array where characters will be copied, whereas the destIndex is the starting position in destination where characters will be copied. The count parameter is the number of characters to be copied.ExampleLet us now see an example - Live Demousing ... Read More

Clone Method in C# Queue

AmitDiwan
Updated on 03-Dec-2019 13:06:32

318 Views

The Queue.Clone() method in C# is used to create a shallow copy of the Queue.SyntaxThe syntax is as follows -public virtual object Clone ();ExampleLet us now see an example - Live Demousing System; using System.Collections; public class Demo {    public static void Main(string[] args) {       Queue queue = new Queue();       queue.Enqueue("One");       queue.Enqueue("Two");       queue.Enqueue("Three");       queue.Enqueue("Four");       queue.Enqueue("Five");       queue.Enqueue("Six");       queue.Enqueue("Seven");       queue.Enqueue("Eight");       Console.WriteLine("Queue...");       foreach(string str in queue) {       ... Read More

Queue Clear Method in C#

AmitDiwan
Updated on 03-Dec-2019 13:01:58

247 Views

The Queue.Clear() method in C# is used to clear all object from Queue.SyntaxThe syntax is as follows -public virtual void Clear ();ExampleLet us now see an example - Live Demousing System; using System.Collections.Generic; public class Demo {    public static void Main() {       Queue queue = new Queue();       queue.Enqueue(100);       queue.Enqueue(200);       queue.Enqueue(300);       queue.Enqueue(400);       queue.Enqueue(500);       queue.Enqueue(600);       queue.Enqueue(700);       queue.Enqueue(800);       queue.Enqueue(900);       queue.Enqueue(1000);       Console.WriteLine("Queue...");       foreach(int i in ... Read More

Double IsPositiveInfinity Method in C#

AmitDiwan
Updated on 03-Dec-2019 12:57:10

208 Views

The Double.IsPositiveInfinity() method in C# is used to return a value indicating whether the specified number evaluates to positive infinity.SyntaxThe syntax is as follows -public static bool IsPositiveInfinity (double val);Above, val is a double-precision floating-point number.ExampleLet us now see an example - Live Demousing System; public class Demo {    public static void Main() {       double d = 1.0/0.0;       Console.WriteLine("Double Value = "+d);       Console.WriteLine("HashCode of Double Value = "+d.GetHashCode());       TypeCode type = d.GetTypeCode();       Console.WriteLine("TypeCode of Double Value = "+type);       Console.WriteLine("Positive Infinity? = "+Double.IsInfinity(d)); ... Read More

StringBuilder Chars Property in C#

AmitDiwan
Updated on 03-Dec-2019 12:49:09

132 Views

The StringBuilder.Chars[] property gets or sets the character at the specified character position in this instance.SyntaxThe syntax is as follows -public char this[int index] { get; set; }Above, the index parameter is the position of the character.ExampleLet us now see an example - Live Demousing System; using System.Text; public class Demo {    public static void Main() {       StringBuilder strBuilder = new StringBuilder("ghgh78hkjj");       int num = 0;       for (int i = 0; i < strBuilder.Length; i++) {          char c = strBuilder[i];          if (Char.IsDigit(c))   ... Read More

Thread CurrentThread Property in C#

AmitDiwan
Updated on 03-Dec-2019 12:45:33

292 Views

The Thread.CurrentThread propertyin C# is used to get the currently running thread.SyntaxThe syntax is as follows -public static System.Threading.Thread CurrentThread { get; }ExampleLet us now see an example - Live Demousing System; using System.Threading; public class Demo {    public static void Main() {       Thread thread = new Thread(new ThreadStart(demo1));       ThreadPool.QueueUserWorkItem(new WaitCallback(demo2));       thread = Thread.CurrentThread;       thread.Name ="Demo Thread";       Console.WriteLine("Current running Thread = "+thread.Name);       Console.WriteLine("Current state of Thread = "+thread.ThreadState);       Console.WriteLine("ManagedThreadId = "+thread.ManagedThreadId);    }    public static void demo1() { ... Read More

C# String Properties

AmitDiwan
Updated on 03-Dec-2019 12:40:51

893 Views

Following are the properties of the String class in C# −Sr.NoProperty & Description1CharsGets the Char object at a specified position in the current String object.2LengthGets the number of characters in the current String object.ExampleLet us see an example - Live Demousing System; public class Demo {    public static void Main() {       string str1 = "h8b9";       string str2 = "abcdef";       Console.WriteLine("Is string1 null or empty? = "+string.IsNullOrEmpty(str1));       Console.WriteLine("Is string2 null or empty? = "+string.IsNullOrEmpty(str2));       bool val = str1 != str2;       Console.WriteLine("Is str1 equal ... Read More

C# String ToUpperInvariant Method

AmitDiwan
Updated on 03-Dec-2019 12:31:04

1K+ Views

The String.ToUpperInvariant() method in C# is used to return a copy of this String object converted to uppercase using the casing rules of the invariant culture.SyntaxThe syntax is as follows -public string ToUpperInvariant ();ExampleLet us now see an example - Live Demousing System; using System.Text; public class Demo {    public static void Main(String[] args) {       string str1 = "one";       string str2 = "TWO";       string str3 = "ThrEE";       Console.WriteLine("String 1 = "+str1);       Console.WriteLine("String1 ToUpperInvariant = "+str1.ToUpperInvariant());       Console.WriteLine("String 2 = "+str2);       ... Read More

C# String ToLowerInvariant Method

AmitDiwan
Updated on 03-Dec-2019 12:18:20

1K+ Views

The String.ToLowerInvariant() method in C# is used to return a copy of this String object converted to lowercase using the casing rules of the invariant culture.SyntaxThe syntax is as follows -public string ToLowerInvariant ();ExampleLet us now see an example - Live Demousing System; using System.Text; public class Demo {    public static void Main(String[] args) {       string str1 = "Pink Floyd";       string str2 = "Ariana";       Console.WriteLine("String 1 = "+str1);       Console.WriteLine("String1 ToLowerInvariant = "+str1.ToLowerInvariant());       Console.WriteLine("String 2 = "+str2);       Console.WriteLine("String2 ToLowerInvariant = "+str2.ToLowerInvariant());     ... Read More

Advertisements