- 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
265 Views
The Byte.Equals(Byte) method in C# returns a value indicating whether this instance and a specified Byte object represent the same value.SyntaxFollowing is the syntax −public bool Equals (byte ob);Above, ob is an object to compare to this instance.ExampleLet us now see an example to implement the Byte.Equals(Byte) method −using System; public class Demo { public static void Main(){ byte b1, b2; b1 = 5; b2 = 5; if (b1.Equals(b2)) Console.Write("b1 = b2"); else Console.Write("b1 is not equal to b2"); } }OutputThis will produce the following output −b1 = b2
47 Views
The Byte.CompareTo(Object) method in C# is used to compare this instance to a specified object and returns an indication of their relative values.SyntaxFollowing is the syntax −public int CompareTo (object val);Above, Val is an object to compare or null.The return value is less than zero if the current instance is less than the value. It’s zero, if the current instance is equal to value, whereas return value is more than zero if the current instance is more than value.ExampleLet us now see an example to implement the Byte.CompareTo(Object) method −using System; public class Demo { public static void Main(){ ... Read More
74 Views
The Byte.CompareTo(Byte) method in C# is used to compare this instance to a specified 8-bit unsigned integer and returns an indication of their relative values.SyntaxFollowing is the syntax −public int CompareTo (byte val);Above, the parameter value is an 8-bit unsigned integer to compare.The return value is less than zero if the current instance is less than the value. It’s zero, if the current instance is equal to value, whereas return value is more than zero if the current instance is more than value.ExampleLet us now see an example to implement the Byte.CompareTo(Byte) method −using System; public class Demo { ... Read More
1K+ Views
The Boolean.TryParse() method in C# is used to convert the specified string representation of a logical value to its Boolean equivalent.SyntaxFollowing is the syntax −public static bool TryParse (string val out bool result);ExampleLet us now see an example to implement the Boolean.TryParse() method −using System; public class Demo { public static void Main(){ bool val; bool flag; val = Boolean.TryParse("true", out flag); Console.WriteLine("Result = "+val); } }OutputThis will produce the following output −Result = TrueExampleLet us now see another example to implement the Boolean.TryParse() method −using ... Read More
711 Views
The DateTime.ToUniversalTime() method in C# is used to convert the value of the current DateTime object to Coordinated Universal Time (UTC).SyntaxFollowing is the syntax −public DateTime ToUniversalTime ();ExampleLet us now see an example to implement the DateTime.ToUniversalTime() method −using System; public class Demo { public static void Main() { DateTime d = new DateTime(2019, 12, 11, 7, 11, 25); Console.WriteLine("Date = {0}", d); DateTime res = d.ToUniversalTime(); Console.WriteLine("String representation = {0}", res); } }OutputThis will produce the following output −Date = 11/11/2019 7:11:25 AM String representation ... Read More
299 Views
The DateTime.ToString() method in C# is used to convert the value of the current DateTime object to its equivalent string representation.SyntaxFollowing is the syntax −ToString(String, IFormatProvider) ToString() ToString(IFormatProvider) ToString(String)ExampleLet us now see an example to implement the DateTime.ToString() method −using System; public class Demo { public static void Main() { DateTime d = new DateTime(2019, 11, 11, 7, 11, 25); Console.WriteLine("Date = {0}", d); string str = d.ToString(); Console.WriteLine("String representation = {0}", str); } }OutputThis will produce the following output −Date = 11/11/2019 7:11:25 AM String ... Read More
841 Views
The DateTime.ToShortTimeString() method in C# is used to convert the value of the current DateTime object to its equivalent short time string representation.SyntaxFollowing is the syntax −public string ToShortTimeString ();ExampleLet us now see an example to implement the DateTime.ToShortTimeString() method −using System; using System.Globalization; public class Demo { public static void Main() { DateTime d = DateTime.Now; Console.WriteLine("Date = {0}", d); Console.WriteLine("Current culture = "+CultureInfo.CurrentCulture.Name); var pattern = CultureInfo.CurrentCulture.DateTimeFormat; string str = d.ToShortTimeString(); Console.WriteLine("Short time string = {0}", pattern.ShortTimePattern); ... Read More
149 Views
The Int32.GetHashCode() method in C# is used to return the hash code for the current instance.SyntaxFollowing is the syntax −public override int GetHashCode ();ExampleLet us now see an example to implement the Int32.GetHashCode() method −using System; public class Demo { public static void Main(){ int val1 = Int32.MinValue; int val2 = 300; Console.WriteLine("Value1 = "+val1); Console.WriteLine("Value2 = "+val2); Console.WriteLine("Are they equal? = "+val1.Equals(val2)); Console.WriteLine("HashCode for Value1 = "+val1.GetHashCode()); Console.WriteLine("HashCode for Value2 = "+val2.GetHashCode()); } }OutputThis will produce ... Read More
158 Views
The Int32.Equals() method in C# is used to return a value indicating whether this instance is equal to a specified object or Int32.SyntaxFollowing is the syntax −public bool Equals (int ob); public override bool Equals (object ob);Above, the parameter ob in the 1st syntax is an Int32 value to compare to this instance. The 2nd syntax ob parameter is an object to compare to this instance.ExampleLet us now see an example to implement the Int32.Equals() method −using System; public class Demo { public static void Main(){ int val1 = 299; int val2 = ... Read More
153 Views
The Type.GetTypeCode() method in C# is used to get the underlying type code of the specified Type.SyntaxFollowing is the syntax −public static TypeCode GetTypeCode (Type type);Above, the type parameter is the type whose underlying type code to get.ExampleLet us now see an example to implement the Type.GetTypeCode() method −using System; public class Demo { public static void Main(){ Type type1 = typeof(double); TypeCode type2 = Type.GetTypeCode(type1); Console.WriteLine("TypeCode = "+type2); } }OutputThis will produce the following output −TypeCode = DoubleExampleLet us now see another example to implement the Type.GetTypeCode() method ... Read More