The Boolean.ToString() method in C# converts the value of this instance to its equivalent string representation (either "True" or "False").SyntaxFollowing is the syntax −public override string ToString ();ExampleLet us now see an example to implement the Boolean.ToString() method −using System; public class Demo { public static void Main(){ bool b = true; string res = b.ToString(); Console.WriteLine("Return Value = "+res); } }OutputThis will produce the following output −Return Value = TrueExampleLet us now see another example to implement the Boolean.ToString() method −using System; public class Demo { public ... Read More
The Boolean.Equals(Object) method in C# returns a value indicating whether this instance is equal to a specified object.SyntaxFollowing is the syntax −public override bool Equals (object ob);Above, ob is an object to compare to this instance.ExampleLet us now see an example to implement the Boolean.Equals(Object) method −using System; public class Demo { public static void Main(){ bool val1 = true; object val2 = 5/10; if (val1.Equals(val2)) Console.WriteLine("Both are equal!"); else Console.WriteLine("Both aren't equal!"); } }OutputThis will produce the following output −Both aren't equal!
The Boolean.Equals(Boolean) method in C# returns a value indicating whether this instance is equal to a specified Boolean object.SyntaxFollowing is the syntax −public bool Equals (bool ob);Above, ob is a Boolean value to compare to this instance.ExampleLet us now see an example to implement the Boolean.Equals(Boolean) method −using System; public class Demo { public static void Main(){ bool b1 = false; bool b2 = true; bool res = b1.Equals(b2); if (res == true) Console.Write("b1 equal to b2"); else ... Read More
The DateTimeOffset.AddMilliseconds() method in C# is used to return a new DateTimeOffset object that adds a specified number of milliseconds to the value of this instance.SyntaxFollowing is the syntax −public DateTimeOffset AddMilliseconds (double val);Above, Val are the milliseconds to be added. To subtract, set a negative value.ExampleLet us now see an example to implement the DateTimeOffset.AddMilliseconds() method −using System; public class Demo { public static void Main() { DateTimeOffset dateTimeOffset = new DateTimeOffset(2019, 08, 10, 4, 20, 10, new TimeSpan(-5, 0, 0)); Console.WriteLine("DateTimeOffset (before adding milliseconds) = {0}", dateTimeOffset); DateTimeOffset ... Read More
The DateTimeOffset.AddHours() method in C# is used to add a specified number of whole and fractional hours to the value of this instance.SyntaxFollowing is the syntax −public DateTimeOffset AddHours (double hrs);Above, hrs are the hours to be added. To subtract hours, include a negative value.ExampleLet us now see an example to implement the DateTimeOffset.AddHours() method −using System; public class Demo { public static void Main() { DateTimeOffset dateTimeOffset = new DateTimeOffset(2019, 10, 10, 3, 15, 0, new TimeSpan(-5, 0, 0)); Console.WriteLine("DateTimeOffset (before adding hours) = {0}", dateTimeOffset); DateTimeOffset res = ... Read More
The DateTimeOffset.AddDays() method in C# is used to return a new DateTimeOffset object that adds a specified number of whole and fractional days to the value of this instance.SyntaxFollowing is the syntax −public DateTimeOffset AddDays (double val);Above, Val is the number of days to be added. To subtract, include a negative value.ExampleLet us now see an example to implement the DateTimeOffset.AddDays() method −using System; public class Demo { public static void Main() { DateTimeOffset dateTimeOffset = new DateTimeOffset(2019, 10, 10, 9, 15, 0, new TimeSpan(-5, 0, 0)); DateTimeOffset res = dateTimeOffset.AddDays(20); ... Read More
The DateTimeOffset.Add() method in C# is used to return a new DateTimeOffset object that adds a specified time interval to the value of this instance.SyntaxFollowing is the syntax −public DateTimeOffset Add (TimeSpan t);ExampleLet us now see an example to implement the DateTimeOffset.Add() method −using System; public class Demo { public static void Main() { DateTimeOffset dateTimeOffset = new DateTimeOffset(2019, 10, 10, 9, 45, 20, new TimeSpan(-10, 0, 0)); TimeSpan ts = new TimeSpan(20, 0, 0); DateTimeOffset res = dateTimeOffset.Add(ts); Console.WriteLine("DateTimeOffset = {0}", res); } }OutputThis will ... Read More
The Type.GetNestedTypes() method in C# is used to get the types nested within the current Type.SyntaxFollowing is the syntax −public Type[] GetNestedTypes (); public abstract Type[] GetNestedTypes (System.Reflection.BindingFlags bindingAttr);ExampleLet us now see an example to implement the Type.GetNestedTypes() method −using System; public class Demo { public static void Main(){ Type type1 = typeof(Subject); try { Type[] type2 = type1.GetNestedTypes(); Console.WriteLine("Nested Types..."); for (int i = 0; i < type2.Length; i++) Console.WriteLine("{0} ", type2[i]); ... Read More
The Type.GetNestedType() method in C# is used to get a specific type of nested within the current Type.SyntaxFollowing is the syntax −public Type GetNestedType (string name); public abstract Type GetNestedType (string name, System.Reflection.BindingFlags bindingAttr);ExampleLet us now see an example to implement the Type.GetNestedType() method −using System; public class Demo { public static void Main(){ Type type1 = typeof(Subject); try { Type type2 = type1.GetNestedType("AdvSubject"); Console.Write("NestedType = "+ type2); } catch (ArgumentNullException e){ Console.Write("{0}", e.GetType(), e.Message); ... Read More
The Decimal.FromOACurrency() method in C# is used to convert the specified 64-bit signed integer, which contains an OLE Automation Currency value, to the equivalent Decimal valueSyntaxFollowing is the syntax −public static decimal FromOACurrency (long val);Above, Val is an OLE Automation Currency value.ExampleLet us now see an example to implement the Decimal.FromOACurrency() method −using System; public class Demo { public static void Main(){ long val = 978576L; decimal res = Decimal.FromOACurrency(val); Console.WriteLine("Decimal Value = "+ res); } }OutputThis will produce the following output −Decimal Value = 97.8576ExampleLet us now see ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP