The Double.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 (double val);Above, val is the 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? = ... Read More
The TimeSpan.FromDays() method in C# is used to return a TimeSpan that represents a specified number of days, where the specification is accurate to the nearest millisecond.SyntaxThe syntax is as follows −public static TimeSpan FromDays (double val);Above, the parameter val is the number of days, accurate to the nearest millisecond.ExampleLet us now see an example − Live Demousing System; public class Demo { public static void Main(){ TimeSpan span1 = new TimeSpan(5, 25, 0); TimeSpan span2 = new TimeSpan(1, 10, 0); TimeSpan span3 = TimeSpan.FromDays(43.999999); Console.WriteLine("TimeSpan1 = "+span1); ... Read More
The BitConverter.ToUInt64() method in C# is used to return a 64-bit unsigned integer converted from eight bytes at a specified position in a byte array.Syntaxpublic static ulong ToUInt64 (byte[] val, int begnIndex);ExampleAbove, val is the byte array, whereas begnIndex is the beginning position within val. Live Demousing System; public class Demo { public static void Main() { byte[] arr = { 0, 0, 1, 3, 5, 7, 9, 11, 15 }; int count = arr.Length; Console.Write("Byte Array... "); for (int i = 0; i < count; i++) { ... Read More
The BitConverter.ToUInt32() method in C# is used to return a 32-bit unsigned integer converted from four bytes at a specified position in a byte array.Syntaxpublic static uint ToUInt32 (byte[] val, int begnIndex);Above, val is the byte array, whereas begnIndex is the starting position withing val.Example Live Demousing System; public class Demo { public static void Main() { byte[] arr = { 0, 3, 5, 10, 15, 2}; int count = arr.Length; Console.Write("Byte Array... "); for (int i = 0; i < count; i++) { ... Read More
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
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
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
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
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
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
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP