Get TypeCode for Value Type Int32 in C#

AmitDiwan
Updated on 11-Dec-2019 07:33:57

152 Views

To get the TypeCode for value type Int32, the code is as follows −Example Live Demousing System; public class Demo {    public static void Main() {       int val1 = 100;       int val2 = 50;       Console.WriteLine("Value1 = "+val1);       Console.WriteLine("Value2 = "+val2);       Console.WriteLine("Are they equal? = "+val1.Equals(val2));         Console.WriteLine("HashCode for Value1 = "+val1.GetHashCode());       Console.WriteLine("HashCode for Value2 = "+val2.GetHashCode());       TypeCode type1 = val1.GetTypeCode();       TypeCode type2 = val2.GetTypeCode();       Console.WriteLine("TypeCode for Value1 = "+type1);   ... Read More

Convert Decimal to 64-bit Unsigned Integer in C#

AmitDiwan
Updated on 11-Dec-2019 07:29:52

599 Views

To convert the value of the specified Decimal to the equivalent 64-bit unsigned integer, the code is as follows −Example Live Demousing System; public class Demo {    public static void Main() {       Decimal val = 99.29m;       Console.WriteLine("Decimal value = "+val);       ulong res = Decimal.ToUInt64(val);       Console.WriteLine("64-bit unsigned integer = "+res);    } }OutputThis will produce the following output −Decimal value = 99.29 64-bit unsigned integer = 99ExampleLet us see another example − Live Demousing System; public class Demo {    public static void Main(){       Decimal val = 0.001m;       Console.WriteLine("Decimal value = ... Read More

Fire jQuery Events with setTimeout

Alex Onsman
Updated on 11-Dec-2019 07:28:43

1K+ Views

The jQuery setTimeout() method is used to set an interval for events to fire.ExampleHere, we will set an interval of 3 seconds for an alert box to load using jQuery events:Live Demo $(document).ready(function(){     $("#button1").click(function(){        setTimeout("alert('Hello World!');", 3000);     }); }); Click Click the above button and wait for 3 seconds. An alert box will generate after 3 seconds.

Detect Image Load via jQuery Event

Alex Onsman
Updated on 11-Dec-2019 07:27:19

2K+ Views

To detect loading of an image with jQuery, use the load() event handler.Note: The load() method deprecated in jQuery version 1.8. It was completely removed in version 3.0. To see its working, add jQuery version for CDN before 3.0.ExampleYou can try to run the following code to learn how to detect when image loads:Live Demo $(document).ready(function(){     $("img").load(function(){         alert("Image successfully loaded.");     }); }); Note: The load() method deprecated in jQuery version 1.8. It was completely removed in version 3.0. To see its working, add jQuery version for CDN before 3.0.

Indicate Equality to a Specified Object or UInt16 in C#

AmitDiwan
Updated on 11-Dec-2019 07:26:44

110 Views

To indicate whether this instance is equal to a specified object or UInt16, the code is as follows −Example Live Demousing System; public class Demo {    public static void Main(){       ushort val1 = 52;       ushort val2 = 10;       bool res = val1.Equals(val2);       Console.WriteLine("Return value (comparison) = "+res);       if (res)          Console.WriteLine("val1 = val2");       else          Console.WriteLine("val1 != val2");    } }OutputThis will produce the following output −Return value (comparison) = False val1 != val2ExampleLet us now ... Read More

Prioritize jQuery Events

Alex Onsman
Updated on 11-Dec-2019 07:25:43

1K+ Views

To prioritize jQuery events, use the event.stopPropagation().ExampleYou can try to run the following code to learn how to prioritize using stopPropogation() method:Live Demo $(document).ready(function(){        var timer;    function out(s) {       if (timer) {         clearTimeout(timer);         timer = null;       }       $("#demo").append(s + "");       timer = setTimeout(function() {         $("#demo").append("-------" + "");         timer = null;       }, 100);    }    $(".li").find('input').click(function(e){     out('li>input');     if ($(this).parent().hasClass("stop")) {         e.stopPropagation();     }    });    $(".li").click(function(e){     out('li');    });    $('input').click(function(e){     out('input');     if ($(this).parent().hasClass("stop")) {         e.stopPropagation();     }    }); }); Demo Demo using stop propagation method

Convert Decimal to Equivalent 32-bit Unsigned Integer in C#

AmitDiwan
Updated on 11-Dec-2019 07:25:14

455 Views

To convert the value of the specified Decimal to the equivalent 32-bit unsigned integer, the code is as follows −Example Live Demousing System; public class Demo {    public static void Main() {       Decimal val = 0.001m;       Console.WriteLine("Decimal value = "+val);       uint res = Decimal.ToUInt32(val);       Console.WriteLine("32-bit unsigned integer = "+res);    } }OutputThis will produce the following output −Decimal value = 0.001 32-bit unsigned integer = 0ExampleLet us see another example − Live Demousing System; public class Demo {    public static void Main() {       Decimal val ... Read More

Difference Between event.preventDefault and event.stopPropagation in jQuery

Alex Onsman
Updated on 11-Dec-2019 07:24:07

235 Views

stopPropogation() methodTo stop the bubbling of an event to parent elements, use the stopPropagation() method.ExampleYou can try to run the following code to learn how to work with stopPropogation() method:Live Demo           jQuery stopPropagation() method                              $(document).ready(function() {             $("div").click(function(event){                alert("This is : " + $(this).text());                                event.stopPropagation();             ... Read More

Get the Number of Key-Value Pairs in a Dictionary in C#

AmitDiwan
Updated on 11-Dec-2019 07:24:04

594 Views

To get the number of key/value pairs in the Dictionary, the code is as follows −Example Live Demousing System; using System.Collections.Generic; public class Demo {    public static void Main(){       Dictionary dict =       new Dictionary();       dict.Add("One", "Chris");       dict.Add("Two", "Steve");       dict.Add("Three", "Messi");       dict.Add("Four", "Ryan");       dict.Add("Five", "Nathan");       Console.WriteLine("Count of elements = "+dict.Count);       Console.WriteLine("Key/value pairs...");       foreach(KeyValuePair res in dict){          Console.WriteLine("Key = {0}, Value = {1}", res.Key, res.Value);       ... Read More

Reinterpret 64-Bit Signed Integer to Double Precision Floating Point in C#

AmitDiwan
Updated on 11-Dec-2019 07:22:35

497 Views

To reinterpret the specified 64-bit signed integer to a double-precision floating point number, the code is as follows −Example Live Demousing System; public class Demo {    public static void Main() {       long d = 9846587687;       Console.Write("Value (64-bit signed integer) = "+d);       double res = BitConverter.Int64BitsToDouble(d);       Console.Write("Value (double-precision floating point number) = "+res);    } }OutputThis will produce the following output −Value (64-bit signed integer) = 9846587687 Value (double-precision floating point number) = 4.86486070491012E-314ExampleLet us see another example − Live Demousing System; public class Demo {    public static void Main() {       long d = 20;     ... Read More

Advertisements