Dictionary Values Property in C#

AmitDiwan
Updated on 06-Nov-2019 05:49:15

341 Views

The Dictionary.Values property in C# is used to fetch all the values in the Dictionary.SyntaxFollowing is the syntax −public System.Collections.Generic.Dictionary.KeyCollection Values{ get; }ExampleLet us now see an example to implement the Dictionary.Values property −using System; using System.Collections.Generic; public class Demo {    public static void Main(){       Dictionary dict = new Dictionary();       dict.Add("One", "Kagido");       dict.Add("Two", "Ngidi");       dict.Add("Three", "Devillers");       dict.Add("Four", "Smith");       dict.Add("Five", "Warner");       Console.WriteLine("Count of elements = "+dict.Count);       Console.WriteLine("Key/value pairs...");       foreach(KeyValuePair res in dict){   ... Read More

Dictionary Class in C#

AmitDiwan
Updated on 06-Nov-2019 05:45:31

866 Views

Dictionary in C# is a collection of keys and values. It is a generic collection class in the System.Collection.Generics namespace.SyntaxFollowing is the syntax −public class DictionaryAbove, the key parameter is the type of keys in the dictionary, whereas TValue is the type of values.ExampleLet us now create a Dictionary and add some elements −using System; using System.Collections.Generic; public class Demo {    public static void Main(){       Dictionary dict = new Dictionary();       dict.Add("One", "John");       dict.Add("Two", "Tom");       dict.Add("Three", "Jacob");       dict.Add("Four", "Kevin");       dict.Add("Five", "Nathan");   ... Read More

Convert To SByte String Using IFormatProvider Method in C#

AmitDiwan
Updated on 06-Nov-2019 05:41:58

184 Views

The Convert.ToSByte() method in C# converts the specified string representation of a number to an equivalent 8-bit signed integer, using the specified culture-specific formatting information.SyntaxFollowing is the syntax −public static sbyte ToSByte (string val, IFormatProvider provider);Above, the parameter value is a string that contains the number to convert. A provider parameter is an object that supplies culture-specific formatting information.ExampleLet us now see an example to implement the Convert.ToSByte() method −using System; using System.Globalization; public class Demo {    public static void Main(){       CultureInfo cultures = new CultureInfo("en-US");       String str = "-2";       ... Read More

Convert toDouble String using IFormatProvider Method in C#

AmitDiwan
Updated on 06-Nov-2019 05:39:32

2K+ Views

The Convert.ToDouble() method in C# converts the specified string representation of a number to an equivalent double-precision floating-point number, using the specified culture-specific formatting information.SyntaxFollowing is the syntax −public static double ToDouble (string val, IFormatProvider provider);Above, the value value is a string that contains the 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.ToDouble() method −using System; using System.Globalization; public class Demo {    public static void Main(){       String val = "876876, 878";       NumberFormatInfo formatProvider = new NumberFormatInfo();     ... Read More

Add Hours to DateTime in C#

AmitDiwan
Updated on 06-Nov-2019 05:37:24

7K+ Views

The DateTime.AddHours() method in C# is used to add the specified number of hours to the value of this instance. This method returns a new DateTime.SyntaxFollowing is the syntax −public DateTime AddHours (double hrs);Above, hrs are the number of hours to be added. The value can be negative to subtract the hours.ExampleLet us now see an example to implement the DateTime.AddHours() methodusing System; public class Demo {    public static void Main(){       DateTime d1 = new DateTime(2019, 11, 2, 9, 0, 10);       DateTime d2 = d1.AddHours(2);       System.Console.WriteLine("Initial DateTime = {0:dd} {0:y}, ... Read More

DateTime AddDays Method in C#

AmitDiwan
Updated on 06-Nov-2019 05:33:59

10K+ Views

The DateTime.AddDays() method in C# is used to add the specified number of days to the value of this instance. This method returns a new DateTime.SyntaxFollowing is the syntax −public DateTime AddDays (double days);Above, the parameter days are the number of days to be added. To subtract, add a negative value.ExampleLet us now see an example to implement the DateTime.AddDays() method −using System; public class Demo {    public static void Main(){       DateTime d1 = new DateTime(2019, 11, 2, 8, 0, 15);       DateTime d2 = d1.AddDays(25);       System.Console.WriteLine("Initial DateTime = {0:y} {0:dd}", ... Read More

DateTime Add Method in C#

AmitDiwan
Updated on 06-Nov-2019 05:30:03

4K+ Views

The DateTime.Add() method in C# is used to return a new DateTime that adds the value of the specified TimeSpan to the value of this instance.SyntaxFollowing is the syntax −public DateTime Add (TimeSpan val);Above, Val is the positive or negative time interval.ExampleLet us now see an example to implement the DateTime.Add() method −using System; public class Demo {    public static void Main(){       DateTime d1 = new DateTime(2019, 3, 7, 8, 0, 15);       TimeSpan span = new TimeSpan(115, 0, 0, 0);       DateTime d2 = d1.Add(span);       System.Console.WriteLine("Initial DateTime = ... Read More

jQuery Submit Selector

AmitDiwan
Updated on 05-Nov-2019 12:46:34

334 Views

The :submit selector in jQuery is used to select button and input elements with type submit.SyntaxThe syntax is as follows −$(":submit")ExampleLet us now see an example to implement the jQuery :submit selector −    .one {       background-color: green;       color: white;       font-size: 18px;       border: 2px blue dashed;    }    $(document).ready(function(){       $(":submit").addClass("one");    }); Fill the Form Username: Set Password: Reserved: Unreserved Products: Accessories Clothing Footwear Electronics Books Submit OutputThis will produce the following output −

jQuery Selected Selector

AmitDiwan
Updated on 05-Nov-2019 12:42:28

166 Views

The :selected selector in jQuery is used to selects option elements that are pre-selected.SyntaxThe syntax is as follows −$(":selected")ExampleLet us now see an example to implement the jQuery :selected selector −    .one {       background-color: green;       color: white;       font-size: 18px;       border: 2px blue dashed;    }    $(document).ready(function(){       $(":selected").addClass("one");    }); Fill the Form Username: Set Password: Reserved: Unreserved Products: Accessories Clothing Footwear Electronics Books Submit OutputThis will produce the following output −

jQuery Root Selector

AmitDiwan
Updated on 05-Nov-2019 12:37:54

189 Views

The :root selector in jQuery is used to select the document's root element.SyntaxThe syntax is as follows −$(":root")ExampleLet us now see an example to implement the jQuery :root selector −    $(document).ready(function(){       $(":root").css("color", "red");    }); Heading One Heading Two Demo text... OutputThis will produce the following output −

Advertisements