Found 2628 Articles for Csharp

Decimal.Divide() Method in C#

AmitDiwan
Updated on 05-Nov-2019 09:44:06

1K+ Views

The Decimal.Divide() method in C# is used to divide two specified Decimal values.SyntaxFollowing is the syntax −public static decimal Divide (decimal val1, decimal val2);Above, val1 is the dividend, whereas val2 is the divisor.ExampleLet us now see an example to implement the Decimal.Divide() method −using System; public class Demo {    public static void Main(){       Decimal val1 = 65.15m;       Decimal val2 = 5.15m;       Console.WriteLine("Decimal 1 = "+val1);       Console.WriteLine("Decimal 2 = "+val2);       Console.WriteLine("After Division = "+(Decimal.Divide(val1, val2)));    } }OutputThis will produce the following output −Decimal 1 ... Read More

Decimal.CompareTo() Method in C#

AmitDiwan
Updated on 05-Nov-2019 09:38:24

76 Views

The Decimal.CompareTo() method in C# is used to compare this instance to a specified object or Decimal and returns an indication of their relative values.SyntaxFollowing is the syntax −public int CompareTo (decimal value); public int CompareTo (object value);ExampleLet us now see an example to implement the Decimal.CompareTo() method −using System; public class Demo {    public static void Main(){       Decimal val1 = 65.15m;       Decimal val2 = 65.15m;       Console.WriteLine("Decimal 1 = "+val1);       Console.WriteLine("Decimal 2 = "+val2);       Console.WriteLine("Comparison Value = "+(val1.CompareTo(val2)));    } }OutputThis will produce the ... Read More

Convert.ToDecimal(String, IFormatProvider) Method in C#

AmitDiwan
Updated on 05-Nov-2019 09:35:32

779 Views

The Convert.ToDecimal() method in C# converts the specified string representation of a number to an equivalent decimal number, using the specified culture-specific formatting information.SyntaxFollowing is the syntax −public static decimal ToDecimal (string val, IFormatProvider provider);Above, Val is a string that contains a number to convert, whereas the provider is an object that supplies culture-specific formatting information.ExampleLet us now see an example to implement the Convert.ToDecimal() method −using System; using System.Globalization; public class Demo {    public static void Main() {       CultureInfo cultures = new CultureInfo("en-US");       String val = "8787";       Console.WriteLine("Converted Decimal ... Read More

Convert.ToDateTime(String, IFormatProvider) Method in C#

AmitDiwan
Updated on 05-Nov-2019 09:34:04

3K+ Views

The Convert.ToDateTime() method in C# converts the specified string representation of a number to an equivalent date and time, using the specified culture-specific formatting information.SyntaxFollowing is the syntax −public static DateTime ToDateTime (string val, IFormatProvider provider);Above, value is a string that contains a date and time to convert, whereas the provider is an object that supplies culture-specific formatting information.ExampleLet us now see an example to implement the Convert.ToDateTime() method −using System; using System.Globalization; public class Demo {    public static void Main(){       CultureInfo cultures = new CultureInfo("en-US");       String val = "11/11/2019";       ... Read More

Convert.ToChar(String, IFormatProvider) Method in C#

AmitDiwan
Updated on 05-Nov-2019 09:32:36

838 Views

The Convert.ToChar() method in C# is used to convert the first character of a specified string to a Unicode character, using specified culture-specific formatting information.SyntaxFollowing is the syntax −public static char ToChar (string val, IFormatProvider provider);Above, the parameter value is a string of length 1 or null and the parameter provider is an object that supplies culture-specific formatting information. This parameter is ignored.ExampleLet us now see an example to implement the Convert.ToChar() method −using System; using System.Globalization; public class Demo {    public static void Main(){       CultureInfo cultures = new CultureInfo("en-US");       String val = ... Read More

DateTime.ToLongTimeString() Method in C#

AmitDiwan
Updated on 05-Nov-2019 09:30:43

911 Views

The DateTime.ToLongTimeString() method in C# is used to convert the value of the current DateTime object to its equivalent long time string representation.SyntaxFollowing is the syntax −public string ToLongTimeString ();ExampleLet us now see an example to implement the DateTime.ToLongTimeString() 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.ToLongTimeString();       Console.WriteLine("Long time string = {0}", pattern.LongTimePattern);     ... Read More

DateTime.ToLongDateString() Method in C#

AmitDiwan
Updated on 05-Nov-2019 09:28:51

3K+ Views

The DateTime.ToLongDateString() method in C# is used to convert the value of the current DateTime object to its equivalent long date string representation.SyntaxFollowing is the syntax −public string ToLongDateString ();ExampleLet us now see an example to implement the DateTime.ToLongDateString() method −using System; public class Demo {    public static void Main() {       DateTime d = new DateTime(2019, 10, 11, 9, 10, 45);       Console.WriteLine("Date = {0}", d);       string str = d.ToLongDateString();       Console.WriteLine("Long date string representation = {0}", str);    } }OutputThis will produce the following output −Date = 10/11/2019 ... Read More

DateTime.ToLocalTime() Method in C#

AmitDiwan
Updated on 05-Nov-2019 09:27:06

283 Views

The DateTime.ToLocalTime() method in C# is used to convert the value of the current DateTime object to local time.SyntaxFollowing is the syntax −public DateTime ToLocalTime ();ExampleLet us now see an example to implement the DateTime.ToLocalTime() method −using System; public class Demo {    public static void Main() {       DateTime d = DateTime.Now;       Console.WriteLine("Date = {0}", d);       DateTime res = d.ToLocalTime();       Console.WriteLine("Local Time = {0}", res);    } }OutputThis will produce the following output −Date = 10/16/2019 8:28:29 AM Local Time = 10/16/2019 8:28:29 AMExampleLet us now see another ... Read More

DateTime.ToFileTimeUtc() Method in C#

AmitDiwan
Updated on 21-Apr-2020 08:02:41

139 Views

The DateTime.ToFileTimeUtc() method in C# is used to convert the value of the current DateTime object to a Windows file time.SyntaxFollowing is the syntax −public long ToFileTimeUtc ();ExampleLet us now see an example to implement the DateTime.ToFileTimeUtc() method −using System; public class Demo {    public static void Main() {       DateTime d = new DateTime(2019, 05, 10, 6, 10, 25);       Console.WriteLine("Date = {0}", d);       long res = d.ToFileTimeUtc();       Console.WriteLine("Windows file time (Utc) = {0}", res);    } }OutputThis will produce the following output −Date = 5/10/2019 6:10:25 AM ... Read More

Char.ConvertToUtf32(String, Int32) Method in C#

AmitDiwan
Updated on 05-Nov-2019 09:13:24

203 Views

The Char.ConvertToUtf32(String, Int32) method in C# is used to convert the value of a UTF-16 encoded character or surrogate pair at a specified position in a string into a Unicode code point.SyntaxFollowing is the syntax −public static int ConvertToUtf32 (string str, int index);Above, str is the string that contains a character or surrogate pair. The index parameter is the index position of the character or surrogate pair in str.ExampleLet us now see an example to implement the Char.ConvertToUtf32(String, Int32) method −using System; public class Demo {    public static void Main(){       int utf = 0x046;     ... Read More

Advertisements