AmitDiwan

AmitDiwan

8,390 Articles Published

Articles by AmitDiwan

Page 739 of 839

Type.GetTypeFromHandle() Method in C#

AmitDiwan
AmitDiwan
Updated on 05-Nov-2019 212 Views

The Type.GetTypeFromHandle() method in C# is used to get the type referenced by the specified type handle.SyntaxFollowing is the syntax −public static Type GetTypeFromHandle (RuntimeTypeHandle handle);Above, the handle parameter is the object that refers to the type.ExampleLet us now see an example to implement the Type.GetTypeFromHandle() method −using System; public class Demo {    public static void Main(){       Type type1 = typeof(short);       RuntimeTypeHandle typeHandle = Type.GetTypeHandle(type1);       Type type = Type.GetTypeFromHandle(typeHandle);       Console.WriteLine("Attributes = " + type.Attributes);    } }OutputThis will produce the following output −Attributes = AutoLayout, AnsiClass, Class, ...

Read More

Decimal.Floor() Method in C#

AmitDiwan
AmitDiwan
Updated on 05-Nov-2019 573 Views

The Decimal.Floor() method in C# rounds a specified Decimal number to the closest integer toward negative infinity.SyntaxFollowing is the syntax −public static decimal Floor (decimal val);Above, Val is the value to round.ExampleLet us now see an example to implement the Decimal.Floor() method −using System; public class Demo {    public static void Main(){       Decimal val1 = 25.25m;       Decimal val2 = 11.85m;       Console.WriteLine("Decimal 1 = "+val1);       Console.WriteLine("Decimal 2 = "+val2);       Console.WriteLine("Floor (val1) = "+Decimal.Floor(val1));       Console.WriteLine("Floor (val2) = "+Decimal.Floor(val2));    } }OutputThis will produce ...

Read More

Decimal.Divide() Method in C#

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

Cast one of the values in MySQL and perform division with the other?

AmitDiwan
AmitDiwan
Updated on 05-Nov-2019 192 Views

For this, at first, use CAST(). Let us first create a table −mysql> create table DemoTable1352     -> (     -> Value1 int,     -> Value2 int     -> ); Query OK, 0 rows affected (0.54 sec)Insert some records in the table using insert command−mysql> insert into DemoTable1352 values(10, 30); Query OK, 1 row affected (0.42 sec) mysql> insert into DemoTable1352 values(40, 60); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1352 values(110, 130); Query OK, 1 row affected (0.18 sec)Display all records from the table using select statement−mysql> select * from DemoTable1352; This ...

Read More

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

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

Display only the duplicate column names appearing atleast thrice in MySQL

AmitDiwan
AmitDiwan
Updated on 05-Nov-2019 136 Views

Use HAVING COUNT() for this. Let us first create a table −mysql> create table DemoTable1351     -> (     -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,     -> StudentName varchar(40)     -> ); Query OK, 0 rows affected (1.08 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1351(StudentName) values('Chris'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable1351(StudentName) values('Bob'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable1351(StudentName) values('Bob'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable1351(StudentName) values('David'); Query OK, 1 row affected (0.11 ...

Read More

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
Showing 7381–7390 of 8,390 articles
« Prev 1 737 738 739 740 741 839 Next »
Advertisements