Found 2628 Articles for Csharp

StringBuilder.CopyTo() Method in C#

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

203 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

Queue.Clone() Method in C#

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

174 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

80 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

137 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

C# ToLower() Method

AmitDiwan
Updated on 03-Dec-2019 12:52:59

249 Views

The ToLower() method in C# is used to return a copy of this string converted to lowercase.SyntaxThe syntax is as follows -public string ToLower ();ExampleLet us now see an example - Live Demousing System; public class Demo {    public static void Main(String[] args) {       string str1 = "WELCOME!";       string str2 = "Thisisit!";       char[] arr1 = str1.ToCharArray(3, 2);       char[] arr2 = str2.ToCharArray(2, 2);       Console.WriteLine("String1 = "+str1);       Console.WriteLine("String1 ToLower = "+str1.ToLower());       Console.WriteLine("String1 Substring from index4 = " + str1.Substring(4, 4));   ... Read More

StringBuilder.Chars[] Property in C#

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

70 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

175 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

706 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# Substring() Method

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

4K+ Views

The Substring() method in C# is used to retrieve a substring from this instance. The substring starts at a specified character position and continues to the end of the string.SyntaxThe syntax is as follows -public string Substring (int begnIndex); public string Substring (int begnIndex, int len);Above, begnIndex is the zero-based starting character position of a substring in this instance. The len parameter is the number of the substring to retrieveExampleLet us now see an example - Live Demousing System; public class Demo {    public static void Main(String[] args) {       string str1 = "Katherine";       string ... Read More

C# String.ToUpperInvariant Method

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

832 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

Advertisements