Char.TryParse Method in C#

AmitDiwan
Updated on 04-Nov-2019 10:59:21

481 Views

The Char.TryParse() method in C# is used to convert the value of the specified string to its equivalent Unicode character.Syntaxpublic static bool TryParse (string str, out char res);Let us now see an example to implement the Char.TryParse () method −Exampleusing System; public class Demo {    public static void Main(){       bool res;       Char ch;       res = Char.TryParse("10", out ch);       Console.WriteLine(res);       Console.WriteLine(ch.ToString());    } }OutputThis will produce the following output −FalseLet us now see another example −Exampleusing System; public class Demo {    public static void ... Read More

Char.ToUpperInvariant Method in C#

AmitDiwan
Updated on 04-Nov-2019 10:57:49

233 Views

The Char.ToUpperInvariant() method in C# is used to convert the value of a Unicode character to its uppercase equivalent using the casing rules of the invariant culture.Syntaxpublic static char ToUpperInvariant (char ch);Above, the parameter ch is the Unicode character to convert.Let us now see an example to implement the Char.ToUpperInvariant() method −Exampleusing System; public class Demo {    public static void Main(){       char ch = 'q';       char res = Char.ToUpperInvariant(ch);       Console.WriteLine("Value = "+ch);       Console.WriteLine("Uppercase Equivalent = "+res);    } }OutputThis will produce the following output −Value = q ... Read More

Select Words from Text in a MySQL Table

AmitDiwan
Updated on 04-Nov-2019 10:56:56

311 Views

Let us first create a table −mysql> create table DemoTable1316 -> ( -> Value varchar(40) -> ); Query OK, 0 rows affected (0.47 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1316 values('MySQL'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1316 values('Java'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable1316 values('MongoDB'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable1316 values('C++'); Query OK, 1 row affected (0.13 sec)Display all records from the table using select statement −mysql> select *from DemoTable1316;This will produce the following output. These are the ... Read More

Log10 Method in C#

AmitDiwan
Updated on 04-Nov-2019 10:55:43

404 Views

The Math.Log10() method in C# is returned to the base 10 logarithms of a specified number.Syntaxpublic static double Log10 (double val);Here, Val is the number whose logarithm we want.The Log10() method returns −Val parameterReturnsPositiveThe base 10 log of d; that is, log 10d.ZeroNegativeInfinityNegativeNaNEqual to NaNNaNEqual to PositiveInfinityPositiveInfinityLet us now see an example to implement Math.Log10() method −Exampleusing System; public class Demo {    public static void Main(){       double val1 = Double.PositiveInfinity; ;       double val2 = Double.NegativeInfinity;       Console.WriteLine(Math.Log10(val1));       Console.WriteLine(Math.Log10(val2));    } }OutputThis will produce the following output −∞ NaNLet ... Read More

Convert Empty Values to NULL in MySQL Query

AmitDiwan
Updated on 04-Nov-2019 10:55:35

1K+ Views

It’s easy to convert empty values to NULL using SET and WHERE. Let us first create a table −mysql> create table DemoTable1315 -> ( -> CountryName varchar(10) -> ); Query OK, 0 rows affected (0.60 sec)Insert some records in the table using insert command. We have set some empty values here as well −mysql> insert into DemoTable1315 values('US'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1315 values(''); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable1315 values('UK'); Query OK, 1 row affected (0.70 sec) mysql> insert into DemoTable1315 values(''); Query OK, 1 row affected (0.12 ... Read More

Math Log Method in C#

AmitDiwan
Updated on 04-Nov-2019 10:52:30

1K+ Views

The Math.Log() method in C# is used to return the logarithm of a specified number.Syntaxpublic static double Log(double num) public static double Log(double num, double base)Above, num is the specified number whose logarithm is to be calculated. Here, the base is the base of the logarithm.Let us now see an example to implement the Math.Log() method −Exampleusing System; public class Demo {    public static void Main(){       double val1 = 2.15;       double val2 = -2.15;       Console.WriteLine(Math.Log(val1));       Console.WriteLine(Math.Log(val2));    } }OutputThis will produce the following output −0.765467842139571 NaNExampleLet us ... Read More

MySQL Query to Display Records Ordered by Numeric Difference

AmitDiwan
Updated on 04-Nov-2019 10:46:31

99 Views

Use ORDER BY and set the difference to display records ordered by numeric difference. Following is the syntax −select *from yourTableName order by (yourIntegerColumnName1 - yourIntegerColumnName2);Let us first create a table −mysql> create table DemoTable1313 -> ( -> Name varchar(20), -> Score1 int, -> Score2 int -> ); Query OK, 0 rows affected (3.48 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1313 values('Chris', 40, 60); Query OK, 1 row affected (0.38 sec) mysql> insert into DemoTable1313 values('David', 70, 50); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1313 values('Adam', 35, 30); Query OK, ... Read More

Use a Comma-Separated String in IN Clause in MySQL

AmitDiwan
Updated on 04-Nov-2019 10:46:30

2K+ Views

Set the comma-separated string in the IN() as in the below syntax:select *from yourTableName where yourColumnName IN('yourCommaSeparatedValue');Let us first create a table −mysql> create table DemoTable1314 -> ( -> Number varchar(100) -> ); Query OK, 0 rows affected (0.53 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1314 values('45, 67, 89'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1314 values('10, 20, 50'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1314 values('90, 56, 45'); Query OK, 1 row affected (0.23 sec)Display all records from the table using select statement −mysql> select ... Read More

Single Query to Get Sum of Count from Different Tables in MySQL

AmitDiwan
Updated on 04-Nov-2019 10:42:49

3K+ Views

To get the sum of count from different tables, use UNION ALL. Let us first create a table −mysql> create table DemoTable1 -> ( -> Id int, -> Name varchar(30) -> ); Query OK, 0 rows affected (1.55 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1 values(10, 'Chris Brown'); Query OK, 1 row affected (0.83 sec) mysql> insert into DemoTable1 values(20, 'David Miller'); Query OK, 1 row affected (0.50 sec) mysql> insert into DemoTable1 values(30, 'John Adam'); Query OK, 1 row affected (0.83 sec)Display all records from the table using select statement −mysql> select *from ... Read More

IEEE Remainder Method in C#

AmitDiwan
Updated on 04-Nov-2019 10:40:18

86 Views

The Math.IEEERemainder() method in C# is used to return the remainder resulting from the division of a specified number by another specified number.Syntaxpublic static double IEEERemainder (double dividend, double divisor);Let us now see an example to implement Math.IEEERemainder() method −Exampleusing System; public class Demo {    public static void Main(){       double val1 = 90;       double val2 = 7;       // IEEE Remainder       var rem = Math.IEEERemainder(val1, val2);       Console.WriteLine(rem);    } }OutputThis will produce the following output −-1Let us see another example to implement Math.IEEERemainder() method −Exampleusing ... Read More

Advertisements