- 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)
470 Views
There are two string operators in C#: Equality and Inequality.ExampleLet us see an example of Equality operator − 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)); Console.WriteLine("Is string1 equal to str2? = "+str1 == str2); } }OutputIs string1 null or empty? = False Is string2 null or empty? = False FalseExampleLet us now see an example of C# Inequality operator − Live Demousing System; public class Demo { public ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
202 Views
The Queue.TrimExcess() method in C# is used to set the capacity to the actual number of elements in the Queue, if that number is less than 90 percent of current capacity.Syntaxpublic void TrimExcess ();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..."); ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
2K+ Views
The Object.GetTypeCode() method in C# is used to get the Type of the current instance.SyntaxThe syntax is as follows −public Type GetType ();Example Live Demousing System; public class Demo { public static void Main() { Object ob = new Object(); String str = "Jim"; Type type1 = ob.GetType(); Type type2 = str.GetType(); Console.WriteLine("Type = "+type1); Console.WriteLine("Type = "+type2); Console.WriteLine("Hash Code = "+type1.GetHashCode()); Console.WriteLine("Hash Code = "+type2.GetHashCode()); } }OutputType = System.Object Type = System.String Hash Code = 30015890 Hash Code = 21083178Example Live Demousing System; ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
1K+ Views
The BitConverter.ToString() method in C# is used to convert the numeric value of each element of a specified array of bytes to its equivalent hexadecimal string representation.Syntaxpublic static string ToString (byte[] val);Above, val is the byte array.Example Live Demousing System; public class Demo { public static void Main() { byte[] arr = {0, 10, 2, 5, 32, 45}; int count = arr.Length; Console.Write("Byte Array... "); for (int i = 0; i < count; i++) { Console.Write(""+arr[i]); } Console.WriteLine("Byte ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
50 Views
The Single.Equals() method in C# is used to return a value indicating whether two instances of Single represent the same value.Syntaxpublic bool Equals (float ob); public override bool Equals (object ob);The parameter ob for the both the syntaxes is an object to compare with this instance.Example Live Demousing System; public class Demo { public static void Main() { float f1 = 15.9f; float f2 = 40.2f; Console.WriteLine("Value1 = "+f1); Console.WriteLine("Value2 = "+f2); Console.WriteLine("Are both the values equal? = "+f1.Equals(f2)); } }OutputValue1 = 15.9 Value2 = 40.2 Are both the values equal? = FalseExample Live ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
66 Views
The BitConverter.ToChar() method in C# is used to returns a Unicode character converted from two bytes at a specified position in a byte array.Syntaxpublic static char ToChar (byte[] value, int begnIndex);Above, val is the byte array, whereas begnIndex is the beginning position within val.Example Live Demousing System; public class Demo { public static void Main() { byte[] arr = { 0, 20, 50, 65 }; Console.WriteLine("Array = {0} ", BitConverter.ToString(arr)); for (int i = 1; i < arr.Length - 1; i = i + 2) { ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
163 Views
The Equals() method in C# is used to check whether two String objects have the same value or not.Syntaxbool string.Equals(string s1, string s2)Above, s1 and s2 are the strings to be compared.Example Live Demousing System; public class Demo { public static void Main(string[] args) { string s1 = "Kevin"; string s2 = "Tom"; string s3 = s2; Console.WriteLine("String1 = "+s1); Console.WriteLine("String2 = "+s2); Console.WriteLine("Are both the strings equal? = "+s1.Equals(s2)); Console.WriteLine("Are both the strings equal? = "+s2.Equals(s3)); } ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
98 Views
The Boolean.GetHashCode() method in C# is used to return the hash code for this instance.Syntaxpublic override int GetHashCode ();Example Live Demousing System; public class Demo { public static void Main(String[] args){ string str = "JackSparrow!"; bool val = true; char[] arr = { 'J', 'a'}; Console.WriteLine("String = "+str); Console.WriteLine("String (after trim) = " + str.Trim(arr)); Console.WriteLine("String (Hashcode) = "+str.GetHashCode()); Console.WriteLine("Bool (Hashcode) = "+val.GetHashCode()); } }OutputString = JackSparrow! String (after trim) = ckSparrow! String (Hashcode) = -203134198 Bool (Hashcode) = 1Example Live Demousing System; public class Demo { public static void ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
8K+ Views
The Trim() method in C# is used to return a new string in which all leading and trailing occurrences of a set of specified characters from the current string are removed.Syntaxpublic string Trim (); public string Trim (params char[] trimChars);Above, the trimChars parameter is an array of Unicode characters to remove, or null.Example Live Demousing System; using System.Globalization; public class Demo { public static void Main(String[] args) { string str1 = " JackSparrow!"; string str2 = " @#$PQRSTUV!"; Console.WriteLine("String1 = "+str1); Console.WriteLine("String1 (after trim) = "+str1.Trim()); ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
305 Views
The ToUpper() method in C# is used to return a copy of this string converted to uppercase.Syntaxpublic string ToUpper ();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 ToUpper = "+str1.ToUpper()); Console.WriteLine("String1 Substring from index4 = " + str1.Substring(4, 4)); Console.Write("Character array...String1 ="); for (int i ... Read More