Return Time Zone Offset in Minutes for Current Locale

Anvi Jain
Updated on 23-Jun-2020 08:13:23

273 Views

JavaScript date getTimezoneOffset() method returns the time-zone offset in minutes for the current locale. The time-zone offset is the minutes in difference; the Greenwich Mean Time (GMT) is relative to your local time.ExampleYou can try to run the following code to return the time-one offset in minutes −           JavaScript getTimezoneOffset Method                        var dt = new Date();          var tz = dt.getTimezoneOffset();                    document.write("getTimezoneOffset() : " + tz );          

C# Program to Find a Key in a Hashtable

karthikeya Boyini
Updated on 23-Jun-2020 08:13:17

466 Views

Set Hashtable collection with elements.Hashtable h = new Hashtable(); h.Add(1, "Jack"); h.Add(2, "Henry"); h.Add(3, "Ben"); h.Add(4, "Chris");Let’s say now you need to find any key, then use the Contains() method. We are finding key 3 here −h.Contains(3);The following is the complete example.Example Live Demousing System; using System.Collections; public class Demo {    public static void Main() {       Hashtable h = new Hashtable();       h.Add(1, "Jack");       h.Add(2, "Henry");       h.Add(3, "Ben");       h.Add(4, "Chris");       Console.WriteLine("Keys and Values list:");       foreach (var key in h.Keys ) ... Read More

C# Program to Find a Value in a Hashtable

George John
Updated on 23-Jun-2020 08:12:48

313 Views

Set Hahtable collection with elements.Hashtable h = new Hashtable(); h.Add(1, "Jack"); h.Add(2, "Henry"); h.Add(3, "Ben"); h.Add(4, "Chris");Let’s say now you need to find a value, then use the ContainsValue() method.We are finding value “Chris” here −h.ContainsValue(“Chris”);Example Live Demousing System; using System.Collections; public class Demo {    public static void Main() {       Hashtable h = new Hashtable();       h.Add(1, "Jack");       h.Add(2, "Henry");       h.Add(3, "Ben");       h.Add(4, "Chris");       Console.WriteLine("Keys and Values list:");       foreach (var key in h.Keys ) {          Console.WriteLine("Key ... Read More

Methods Supported by W3C DOM

Srinivas Gorla
Updated on 23-Jun-2020 08:12:46

145 Views

The following are the method supported by W3C DOM −Sr.NoProperty & Description1createAttribute( name)Returns a newly-created Attr node with the specified name.Ex − document.createAttribute( name)2createComment( text)Creates and returns a new Comment node containing the specified text.Ex − document.createComment( text)3createDocumentFragment( )Creates and returns an empty DocumentFragment node.Ex − document.createDocumentFragment( )4createElement( tagName)Creates and returns a new Element node with the specified tag name.Ex − document.createElement( tagName)5createTextNode( text)Creates and returns a new Text node that contains the specified text.Ex − document.createTextNode( text)6getElementById( id)Returns the Element of this document that has the specified value for its id attribute, or null if no such Element exists ... Read More

Convert toDouble Method in C#

Samual Sam
Updated on 23-Jun-2020 08:12:13

10K+ Views

To convert a specified value to a double-precision floating-point number, use Convert.ToDouble() method.The following is our long value −long[] val = { 340, -200};Now convert it to Double.double result; result = Convert.ToDouble(val);Example Live Demousing System; public class Demo {    public static void Main() {       long[] val = { 340, -200};       double result;       // long to double       foreach (long number in val) {          result = Convert.ToDouble(number);          Console.WriteLine("Converted {0} value to {1}",number, result);       }    } }OutputConverted 340 value to 340 Converted -200 value to -200

Return Number of Images in a Document with JavaScript

Samual Sam
Updated on 23-Jun-2020 08:12:05

1K+ Views

To return the number of images in a document, use the images property in JavaScript.ExampleYou can try to run the following code to get the count of images −Live Demo                                            var val = document.images.length;          document.write("Number of images in the document: "+val);          

ContainsKey Method in C# HashTable

karthikeya Boyini
Updated on 23-Jun-2020 08:11:40

288 Views

Set a Hashtable collection and add some elements to it.Hashtable h = new Hashtable(); h.Add(1, "Sam"); h.Add(2, "Jack"); h.Add(3, "Andy"); h.Add(4, "Katie"); h.Add(5, "Beth"); h.Add(6, "Benjamin");Use the ContainsKey() method to check whether a key exists in a Hashtable or not.Let’s check for key 3. It returns True of the key is found.h.ContainsKey(3));Example Live Demousing System; using System.Collections; public class Demo {    public static void Main() {       Hashtable h = new Hashtable();       h.Add(1, "Sam");       h.Add(2, "Jack");       h.Add(3, "Andy");       h.Add(4, "Katie");       h.Add(5, "Beth");   ... Read More

Return ID of the First Image in a Document with JavaScript

Kumar Varma
Updated on 23-Jun-2020 08:11:36

530 Views

To return the id of the first image, use the images property in JavaScript.ExampleYou can try to run the following code to return the id of the first image in a document −Live Demo                                            var val = document.images.length;          document.write("Number of images in the document: "+val);          document.write("The id of the first image: "+document.images[0].id);          

Clear a Hashtable in C#

Chandu yadav
Updated on 23-Jun-2020 08:11:04

470 Views

Clear a Hashtable, using the Clear() method in C#.The following is our Hashtable −Hashtable h = new Hashtable(); h.Add(1, "Amit"); h.Add(2, "Sachin"); h.Add(3, "Rahul");Use the clear method.h.Clear();If you will now try to display the Hashtable, nothing would get display since the Hashtable is empty.Example Live Demousing System; using System.Collections; public class Demo {    public static void Main() {       Hashtable h = new Hashtable();       h.Add(1, "Amit");       h.Add(2, "Sachin");       h.Add(3, "Rahul");       Console.WriteLine("Keys and Values list:");       foreach (var key in h.Keys ) {     ... Read More

Access First Element in a Dictionary using C#

Samual Sam
Updated on 23-Jun-2020 08:09:48

5K+ Views

The following is our Dictionary with some elements −Dictionary d = new Dictionary() {    {1,"Electronics"},    {2, "Clothing"},    {3,"Toys"},    {4,"Footwear"},    {5, "Accessories"} };Now to display the first element, set the key like this.d[1];The above displays the first element.Example Live Demousing System; using System.Collections.Generic; public class Program {    public static void Main() {       Dictionary d = new Dictionary() {          {1,"Electronics"},          {2, "Clothing"},          {3,"Toys"},          {4,"Footwear"},          {5, "Accessories"}       };       foreach (KeyValuePair ele in d) {          Console.WriteLine("Key = {0}, Value = {1}", ele.Key, ele.Value);       }       Console.WriteLine("First element: "+d[1]);    } }OutputKey = 1, Value = Electronics Key = 2, Value = Clothing Key = 3, Value = Toys Key = 4, Value = Footwear Key = 5, Value = Accessories First element: Electronics

Advertisements