Csharp Articles

Page 189 of 196

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

AmitDiwan
AmitDiwan
Updated on 05-Nov-2019 1K+ 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
AmitDiwan
Updated on 05-Nov-2019 1K+ 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
AmitDiwan
Updated on 05-Nov-2019 4K+ 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
AmitDiwan
Updated on 05-Nov-2019 471 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

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

AmitDiwan
AmitDiwan
Updated on 05-Nov-2019 342 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

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

AmitDiwan
AmitDiwan
Updated on 05-Nov-2019 462 Views

The Convert.ToBoolean() method in C# is used to convert a specified value to an equivalent Boolean value.SyntaxFollowing is the syntax −public static bool ToBoolean (string val, IFormatProvider provider);Above, Val is a string that contains the value of either TrueString or FalseString, whereas the provider is an object that supplies culture-specific formatting information.ExampleLet us now see an example to implement the Convert.ToBoolean() method −using System; using System.Globalization; public class Demo {    public static void Main(){       CultureInfo cultures = new CultureInfo("en-US");       String str = "true";       Console.WriteLine("Converted bool value...");       bool ...

Read More

DateTime.DaysInMonth() Method in C#

AmitDiwan
AmitDiwan
Updated on 05-Nov-2019 3K+ Views

The DateTime.DaysInMonth() method in C# is used to return the number of days in the specified month and year. For example, 31 for month value 1 i.e. January.SyntaxFollowing is the syntax −public static int DaysInMonth (int year, int month);ExampleLet us now see an example to implement the DateTime.DaysInMonth() method −using System; public class Demo {    public static void Main() {       DateTime date1 = new DateTime(2019, 08, 20, 6, 20, 40);       DateTime date2 = new DateTime(2019, 06, 20, 6, 20, 40);       Console.WriteLine("DateTime 1 = {0:dd} {0:y}, {0:hh}:{0:mm}:{0:ss} ", date1);     ...

Read More

UInt16.GetTypeCode() Method in C# with Examples

AmitDiwan
AmitDiwan
Updated on 05-Nov-2019 121 Views

The UInt16.GetTypeCode() method in C# is used to return the TypeCode for value type UInt16.SyntaxFollowing is the syntax −public TypeCode GetTypeCode ();ExampleLet us now see an example to implement the UInt16.GetTypeCode() method −using System; public class Demo {    public static void Main(){       ushort val1 = 55;       ushort val2 = 100;       TypeCode type1 = val1.GetTypeCode();       TypeCode type2 = val2.GetTypeCode();       Console.WriteLine("Typecode for val1 = "+type1);       Console.WriteLine("Typecode for val1 = "+type2);    } }OutputThis will produce the following output −Typecode for val1 = UInt16 ...

Read More

UInt16.Equals Method in C# with Examples

AmitDiwan
AmitDiwan
Updated on 05-Nov-2019 172 Views

The UInt16.Equals() method in C# returns a value indicating whether this instance is equal to a specified object or UInt16.SyntaxFollowing is the syntax −public override bool Equals (object ob); public bool Equals (ushort ob);Above, the parameter ob for the 1st syntax is an object to compare to this instance and the parameter ob for the 2nd syntax is the 16-bit unsigned integer to compare to this instance.ExampleLet us now see an example to implement the UInt16.Equals() method −using System; public class Demo {    public static void Main(){       ushort val1 = 52;       ushort val2 ...

Read More

UInt16.CompareTo() Method in C# with Examples

AmitDiwan
AmitDiwan
Updated on 05-Nov-2019 222 Views

The UInt16.CompareTo() method in C# is used to compare the current instance to a specified object or UInt16 and returns an indication of their relative values.SyntaxFollowing is the syntax −public int CompareTo (object val); public int CompareTo (ushort val;Above, the value for the 1st syntax is an object to compare. The value for 2nd syntax is an unsigned integer to compare.The return value is 0 if the current instance is equal to value. It’s less than zero if the current instance is less than val. The return value is more than zero if the current instance is greater than the ...

Read More
Showing 1881–1890 of 1,951 articles
« Prev 1 187 188 189 190 191 196 Next »
Advertisements