Found 2628 Articles for Csharp

Stack.ToString() Method in C# with examples

AmitDiwan
Updated on 04-Dec-2019 12:43:14

796 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

Stack.ToArray() Method in C#

AmitDiwan
Updated on 04-Dec-2019 12:38:36

196 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

Stack.Synchronized() Method in C#

AmitDiwan
Updated on 04-Dec-2019 12:33:33

48 Views

The Stack.Synchronized() method in C# is used to returns a synchronized (thread safe) wrapper for the Stack.SyntaxThe syntax is as follows −public static System.Collections.Stack Synchronized (System.Collections.Stack stack);Above, the parameter stack is the stack to synchronize.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);   ... Read More

Single.IsNaN() Method in C# with Examples

AmitDiwan
Updated on 04-Dec-2019 12:28:12

100 Views

The Single.IsNan() method in C# is used to return a value that indicates whether the specified value is not a number (NaN).SyntaxThe syntax is as follows −public static bool IsNaN (float f);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 = 45.5f;       Console.WriteLine("Value1 = "+f1);       Console.WriteLine("Hashcode for Value1 = "+f1.GetHashCode());       Console.WriteLine("TypeCode for Value1 = "+f1.GetTypeCode());       Console.WriteLine("Is Value1 value ... Read More

Stack.Clear() Method in C#

AmitDiwan
Updated on 04-Dec-2019 12:24:23

197 Views

The Stack.Clear() method in C# is used to removes all objects from the Stack.SyntaxThe syntax is as follows −public virtual void Clear ();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

Queue.Peek Method in C#

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

281 Views

The Queue.Peek() method in C# is used to return the object at the beginning of the Queue without removing it.SyntaxThe syntax is as follows −public virtual object Peek ();ExampleLet us now see an example − Live Demousing System; using System.Collections; public class Demo {    public static void Main() {       Queue queue = new Queue();       queue.Enqueue("AB");       queue.Enqueue("BC");       queue.Enqueue("CD");       queue.Enqueue("DE");       queue.Enqueue("EF");       queue.Enqueue("FG");       queue.Enqueue("GH");       queue.Enqueue("HI");       Console.WriteLine("Queue...");       IEnumerator demoEnum = queue.GetEnumerator(); ... Read More

Queue.IsSynchronized Property in C#

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

43 Views

The Queue.IsSynchronized() method in C# is used to GET a value indicating whether access to the Queue is synchronized (thread safe).SyntaxThe syntax is as follows −public virtual bool IsSynchronized { get; }ExampleLet us now see an example − Live Demousing System; using System.Collections; 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); ... Read More

Single.GetHashCode() Method in C# with Examples

AmitDiwan
Updated on 04-Dec-2019 12:05:07

145 Views

The Single.GetHashCode() method in C# is used to return the hash code for this instance.SyntaxThe syntax is as follows −public override int GetHashCode ();ExampleLet us now see an example − Live Demousing System; public class Demo {    public static void Main() {       float f1 = 40.2f;       object f2 = 50.5f;       Console.WriteLine("Value1 = "+f1);       Console.WriteLine("HashCode of Value1 = "+f1.GetHashCode());       Console.WriteLine("Value2 = "+f2);       Console.WriteLine("HashCode of Value2 = "+f2.GetHashCode());       Console.WriteLine("Are both the values equal? = "+f1.Equals(f2));    } }OutputThis will produce the ... Read More

SByte.GetHashCode() Method in C# with Examples

AmitDiwan
Updated on 04-Dec-2019 12:02:32

31 Views

The SByte.GetHashCode() method in C# is used to return the hash code for this instance.SyntaxThe syntax is as follows −public override int GetHashCode ();ExampleLet us now see an example − Live Demousing System; public class Demo {    public static void Main() {       sbyte s1 = 50;       sbyte s2 = 75;       Console.WriteLine("Value of S1 = "+s1);       Console.WriteLine("Value of S2 = "+s2);       Console.WriteLine("Is s1 and s2 equal? = "+s1.Equals(s2));       Console.WriteLine("HashCode for s1 = "+s1.GetHashCode());       Console.WriteLine("HashCode for s2 = "+s1.GetHashCode());    } ... Read More

SByte.GetTypeCode Method in C# with Examples

AmitDiwan
Updated on 04-Dec-2019 11:58:44

47 Views

The SByte.GetTypeCode() method in C# is used to return the TypeCode for value type SByte.SyntaxThe syntax is as follows −public TypeCode GetTypeCode ();ExampleLet us now see an example − Live Demousing System; public class Demo {    public static void Main() {       sbyte s1 = 55;       object s2 = (sbyte)55;       Console.WriteLine("Value of S1 = "+s1);       Console.WriteLine("Value of S2 = "+s2);       int res = s1.CompareTo(s2);       if (res > 0)          Console.WriteLine("s1 > s2");       else if (res < 0) ... Read More

Advertisements