Convert String to Unicode Character in C#

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

401 Views

To convert the value of the specified string to its equivalent Unicode character, the code is as follows −Example Live Demousing 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 −FalseExampleLet us now see another example − Live Demousing System; public class Demo {    public static void Main(){       bool res;       Char ch;       res = Char.TryParse("P", out ch);       Console.WriteLine(res);       Console.WriteLine(ch.ToString());    } }OutputThis will produce the following output −True P

Convert Double Precision Floating Point to 64-bit Signed Integer in C#

AmitDiwan
Updated on 11-Dec-2019 07:20:20

407 Views

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

Convert DateTime Object to Windows File Time in C#

AmitDiwan
Updated on 11-Dec-2019 07:17:06

316 Views

To convert the value of the current DateTime object to a Windows file time, the code is as follows −Example Live Demousing System; public class Demo {    public static void Main() {       DateTime d = DateTime.Now;       Console.WriteLine("Date = {0}", d);       long res = d.ToFileTime();       Console.WriteLine("Windows file time = {0}", res);    } }OutputThis will produce the following output −Date = 10/16/2019 8:17:26 AM Windows file time = 132156874462559390ExampleLet us see another example − Live Demousing System; public class Demo {    public static void Main() {       DateTime d = new DateTime(2019, 05, 10, 6, ... Read More

Use Strings in Switch Statement in C#

AmitDiwan
Updated on 11-Dec-2019 07:15:20

2K+ Views

A switch statement allows a variable to be tested for equality against a list of values. Each value is called a case, and the variable being switched on is checked for each switch case.ExampleHere is an example to use strings in a switch statement − Live Demousing System; public class Demo {    public static void Main(String[] args){       string grades = "A1";       switch (grades) {          case "A1":             Console.WriteLine("Very good!");             break;          case "A2":       ... Read More

Get Enumerator to Iterate Through StringDictionary in C#

AmitDiwan
Updated on 11-Dec-2019 07:13:32

123 Views

To get an enumerator that iterates through StringDictionary, the code is as follows −Example Live Demousing System; using System.Collections; using System.Collections.Specialized; public class Demo {    public static void Main() {       StringDictionary strDict1 = new StringDictionary();       strDict1.Add("A", "John");       strDict1.Add("B", "Andy");       strDict1.Add("C", "Tim");       strDict1.Add("D", "Ryan");       strDict1.Add("E", "Kevin");       strDict1.Add("F", "Katie");       strDict1.Add("G", "Brad");       Console.WriteLine("StringDictionary1 elements...");       foreach(DictionaryEntry de in strDict1) {          Console.WriteLine(de.Key + " " + de.Value);       } ... Read More

Store and Reproduce jQuery Events

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

225 Views

To store and reproduce jQuery events, use console to log.ExampleYou can try to run the following code to learn how to store and reproduce jQuery events:Live Demo $(document).ready(function(){     window.events = []     $("#track").click(function(event){        window.events.push(event)            $.each(window.events, function(i, item){           console.log(i, item);        });    }); }); Track

Get Enumerator to Iterate Through SortedSet in C#

AmitDiwan
Updated on 11-Dec-2019 07:10:21

129 Views

To get an enumerator that iterates through the SortedSet, the code is as follows −Example Live Demousing System; using System.Collections.Generic; public class Demo {    public static void Main() {       SortedSet set1 = new SortedSet();       set1.Add("AB");       set1.Add("BC");       set1.Add("CD");       set1.Add("EF");       Console.WriteLine("Elements in SortedSet1...");       foreach (string res in set1) {          Console.WriteLine(res);       }       SortedSet set2 = new SortedSet();       set2.Add("BC");       set2.Add("CD");       set2.Add("DE");       ... Read More

Create Shallow Copy of ArrayList in C#

AmitDiwan
Updated on 11-Dec-2019 07:09:00

259 Views

To create a shallow copy of ArrayList in C#, the code is as follows −Example Live Demousing System; using System.Collections; public class Demo {    public static void Main(){       ArrayList list = new ArrayList();       list.Add("One");       list.Add("Two");       list.Add("Three");       list.Add("Four");       list.Add("Five");       list.Add("Six");       list.Add("Seven");       list.Add("Eight");       Console.WriteLine("ArrayList elements...");       foreach(string str in list){          Console.WriteLine(str);       }       Console.WriteLine("ArrayList is read-only? = "+list.IsReadOnly);       ... Read More

Check If Every List Element Matches Predicate Conditions in C#

AmitDiwan
Updated on 11-Dec-2019 07:06:51

385 Views

To check if every List element matches the predicate conditions, the code is as follows −Example Live Demousing System; using System.Collections.Generic; public class Demo {    private static bool demo(int i) {       return ((i % 10) == 0);    }    public static void Main(String[] args) {       List list = new List();       list.Add(200);       list.Add(215);       list.Add(310);       list.Add(500);       list.Add(600);       Console.WriteLine("List elements...");       foreach (int i in list) {          Console.WriteLine(i);       } ... Read More

Trigger Same Function with jQuery for Multiple Events

Amit D
Updated on 11-Dec-2019 07:06:41

5K+ Views

To trigger the same function with multiple events, use the jQuery on() method with multiple events such as click, dblclick, mouse enter, mouse leave, hover, etc.ExampleYou can try to run the following code to learn how to work the same function with jQuery multiple events:Live Demo $(document).ready(function(){     $("p").on({             mouseenter: function(){             $(this).css("background-color", "gray");         },                   mouseleave: function(){             $(this).css("background-color", "red");         },                 dblclick: function(){             $(this).css("background-color", "yellow");         }             }); }); Click, double click and move the mouse pointer.

Advertisements