- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 2628 Articles for Csharp
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
76 Views
The StringBuilder.EnsureCapacity() method in C# is used to ensure that the capacity of this instance of StringBuilder is at least the specified value.SyntaxThe syntax is as follows −public int EnsureCapacity (int capacity);Above, the parameter capacity is the minimum capacity to ensure.ExampleLet us now see an example − Live Demousing System; using System.Text; public class Demo{ public static void Main(){ StringBuilder strBuilder = new StringBuilder("jhbjhb"); Console.WriteLine("String = "+strBuilder); Console.WriteLine("StringBuilder capacity= "+strBuilder.Capacity); strBuilder.EnsureCapacity(20); Console.WriteLine("StringBuilder capacity= "+strBuilder.Capacity); char[] arr = new char[5] {'a', 'b', 'c', ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
1K+ Views
The IsNullOrEmpty() method in C# is used to indicate whether the specified string is null or an empty string ("").SyntaxThe syntax is as follows−public static bool IsNullOrEmpty (string val);Above, the value val is the string to test.ExampleLet us now see an example − Live Demousing System; public class Demo { public static void Main(){ string str1 = "Amit"; string str2 = " "; Console.WriteLine("Is string1 null or empty? = "+string.IsNullOrEmpty(str1)); Console.WriteLine("Is string2 null or empty? = "+string.IsNullOrEmpty(str2)); } }OutputThis will produce the following output −Is string1 null ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
371 Views
The Int64.ToString() method in C# is used to convert the numeric value of this instance to its equivalent string representation.SyntaxThe syntax is as follows −public override string ToString (); public string ToString (string format);Above, the parameter format is a numeric format string.ExampleLet us now see an example − Live Demousing System; public class Demo { public static void Main(){ long val1 = 0; long val2 = Int64.MaxValue; Console.WriteLine("Value1 = "+val1.ToString()); Console.WriteLine("Value2 = "+val2.ToString()); Console.WriteLine("Are they equal? = "+val1.Equals(val2)); Console.WriteLine("Value1 (HashCode) = "+val1.GetHashCode()); ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
221 Views
The Random.NextBytes() method in C# is used to fill the elements of a specified array of bytes with random numbers.SyntaxThe syntax is as follows −public virtual void NextBytes (byte[] buffer);Above the buffer is the array of bytes.ExampleLet us now see an example − Live Demousing System; public class Demo { public static void Main(){ Random r = new Random(); Random r2 = new Random(); Random r3 = new Random(); Byte[] arr = new Byte[5]; r3.NextBytes(arr); Console.WriteLine("Random numbers....."); for (int i = 1; i
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
71 Views
The Queue.GetEnumerator() method in C# is used to return an enumerator that iterates through the Queue.SyntaxThe syntax is as follows:public virtual System.Collections.IEnumerator GetEnumerator ();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); Console.WriteLine("Queue1..."); IEnumerator demoEnum = queue.GetEnumerator(); while (demoEnum.MoveNext()){ Console.WriteLine(demoEnum.Current); } Queue queue2 = new Queue(); ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
79 Views
The Single.IsInfinity() method in C# is used to return a value indicating whether the specified number evaluates to negative or positive infinity.SyntaxThe syntax is as follows −public static bool IsInfinity (float val);Above, 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 = 19.3f; float f2 = Single.MaxValue; 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 ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
2K+ Views
The Int 64 struct represents a 64-bit signed integer. It is an immutable value type representing signed integers with values: negative 9, 223, 372, 036, 854, 775, 808 through positive 9, 223, 372, 036, 854, 775, 807.Following are the fields of Int 64 −FieldDescriptionMaxValueRepresents the largest possible value of an Int64. This field is constant.MinValueRepresents the smallest possible value of an Int64. This field is constant.Following are some of the methods −FieldDescriptionCompareTo(Int64)Compares this instance to a specified 64-bit signed integer and returns an indication of their relative values.CompareTo(Object)Compares this instance to a specified object and returns an indication of their ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
694 Views
The Insert() method in C# is used to return a new string in which a specified string is inserted at a specified index position in this instance.SyntaxThe syntax is as follows −public string Insert (int begnIndex, string val);Above, the parameter begnIndex is the zero-based index position of the insertion, whereas val is the string to insert.ExampleLet us now see an example − Live Demousing System; public class Demo{ public static void Main(){ String str = "JohnWick"; Console.WriteLine("Initial string = "+str); String res = str.Insert(5, " "); Console.WriteLine("Updated = ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
663 Views
The Random.NextDouble() method in C# is used to return a random floating-point number that is greater than or equal to 0.0, and less than 1.0.SyntaxThe syntax is as follows −public virtual double NextDouble ();ExampleLet us now see an example − Live Demousing System; public class Demo { public static void Main(){ Random r1 = new Random(); Random r2 = new Random(); Byte[] arr = new Byte[2]; r1.NextBytes(arr); Console.WriteLine("Random numbers in the byte array..."); for (int i = 0; i < 2; i++) ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
86 Views
The SortedDictionary.Remove() method in C# is used to remove the element with the specified key from the SortedDictionary.OutputThe syntax is as follows −public bool Remove (TKey key);Above, the parameter key is the key of the element to remove.ExampleLet us now see an example − Live Demousing System; using System.Collections; using System.Collections.Generic; public class Demo { public static void Main(){ SortedDictionary sortedDict = new SortedDictionary(); sortedDict.Add(100, "Mobile"); sortedDict.Add(200, "Laptop"); sortedDict.Add(300, "Desktop"); sortedDict.Add(400, "Speakers"); sortedDict.Add(500, "Headphone"); sortedDict.Add(600, "Earphone"); ... Read More