jQuery :first-of-type Selector

AmitDiwan
Updated on 05-Nov-2019 10:10:07

238 Views

The :first-of-type selector in jQuery is used to select elements, which are the first element of their parent.SyntaxThe syntax is as follows −$(":first-of-type")ExampleLet us now see an example to implement the :first-of-type() selector −    .demo {       background-color: red;       color: white;       font-size: 16px;       border: 2px blue dashed;    }    $(document).ready(function(){       $("p:first-of-type").addClass("demo");    }); This is the first line! This is the second line! This is the third line! One Two Three Four A B This is the last line. OutputThis will produce the following output −

jQuery First Child Selector

AmitDiwan
Updated on 05-Nov-2019 10:06:38

334 Views

The :first-child selector in jQuery is used to select all elements, which are the first child of their parent.SyntaxThe syntax is as follows −$(":first-child")ExampleLet us now see an example to implement the :first-child() selector −    .demo {       background-color: red;       color: white;       font-size: 16px;       border: 2px blue dashed;    }    $(document).ready(function(){       $("p:first-child").addClass("demo");    }); This is the first line! This is the second line! This is the third line! One Two Three Four This is the last line. OutputThis will produce the following output −

Type GetFields Method in C#

AmitDiwan
Updated on 05-Nov-2019 09:55:31

308 Views

The Type.GetFields() method in C# is used to get the fields of the current Type.SyntaxFollowing is the syntax −public System.Reflection.FieldInfo[] GetFields ();ExampleLet us now see an example to implement the Type.GetFields() method −using System; using System.Reflection; public class Demo {    public static void Main(){       Type type = typeof(System.String);       FieldInfo [] fields = type.GetFields(BindingFlags.Static | BindingFlags.NonPublic);       Console.WriteLine ("Following are the non-public fields=");       foreach (FieldInfo myField in fields){          Console.WriteLine(myField.ToString());       }    } }OutputThis will produce the following output −Following are the non-public ... Read More

GetTypeHandle Method in C#

AmitDiwan
Updated on 05-Nov-2019 09:53:41

104 Views

The Type.GetTypeHandle() method in C# is used to get the handle for the Type of a specified object.SyntaxFollowing is the syntax −public static RuntimeTypeHandle GetTypeHandle (object ob);Above, ob is the object for which to get the type handle.Exampleusing System; public class Demo {    public static void Main(){       Type type1 = typeof(System.Type);       RuntimeTypeHandle typeHandle = Type.GetTypeHandle(type1);       Type type = Type.GetTypeFromHandle(typeHandle);       Console.WriteLine("Attributes = " + type.Attributes);       Console.WriteLine("Type Referenced = "+ type);    } }OutputThis will produce the following output −Attributes = AutoLayout, AnsiClass, Class, Serializable, BeforeFieldInit ... Read More

Get Type from Handle Method in C#

AmitDiwan
Updated on 05-Nov-2019 09:50:22

186 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
Updated on 05-Nov-2019 09:48:00

565 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
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

156 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 using IFormatProvider Method in C#

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

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 Values in MySQL and Perform Division

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

184 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

Advertisements