The Custom Specifier in C#

Samual Sam
Updated on 23-Jun-2020 08:06:03

170 Views

A % in a format string would multiply a number by 100 before it is formatted.The percent symbol is added in the number at the location where the % appears.For an example, declare and initialize a double variable.double d = .045;Now, use % custom specifier to multiply number by 100.d.ToString("#0.##%", CultureInfo.InvariantCulture)Example Live Demousing System; using System.Globalization; class Demo {    static void Main() {       double d = .045;       Console.WriteLine(d.ToString("#0.##%", CultureInfo.InvariantCulture));       Console.WriteLine(String.Format(CultureInfo.InvariantCulture, "{0:#0.##%}", d));    } }Output4.5% 4.5%

JavaScript Event When Dragged Element is Dropped

Swarali Sree
Updated on 23-Jun-2020 08:05:55

159 Views

The ondrop event triggers when a dragged element is dropped on the target. You can try to run the following code to learn how to implement ondrop event in JavaScript −ExampleLive Demo                    .drag {             float: left;             width: 100px;             height: 35px;             border: 2px dashed #876587;             margin: 15px;             padding: 10px;          } ... Read More

Clear a Linked List in C#

George John
Updated on 23-Jun-2020 08:05:42

207 Views

Clear a LinkedList using Clear() method.Let us first set a LinkedList.string [] employees = {"Patrick", "Robert", "John", "Jacob", "Jamie"}; LinkedList list = new LinkedList(employees);Now, let us clear the LinkedList.list.Clear();Let us see the complete code.Example Live Demousing System; using System.Collections.Generic; class Demo {    static void Main() {       string [] employees = {"Patrick", "Robert", "John", "Jacob", "Jamie"};       LinkedListlist = new LinkedList(employees);       foreach (var emp in list) {          Console.WriteLine(emp);       }       // clearing list       list.Clear();       Console.WriteLine("LinkedList after removing the ... Read More

Search for a Tab Character Using JavaScript RegExp

Nikitha N
Updated on 23-Jun-2020 08:05:22

829 Views

To find a tab character with JavaScript Regular Expression, use the following −\tExampleYou can try to run the following code to find a tab character. It returns the position where the tab (\t) character is found −           JavaScript Regular Expression                        var myStr = "Simple \t Responsive!";          var reg = /\t/;          var match = myStr.search(reg);          document.write(match);          

Role of Browser Object Model (BOM) in JavaScript

karthikeya Boyini
Updated on 23-Jun-2020 08:04:18

2K+ Views

The Browser Object Model (BOM) in JavaScript includes the properties and methods for JavaScript to interact with the web browser.BOM provides you with a window objects, for example, to show the width and height of the window. It also includes the window.screen object to show the width and height of the screen.ExampleYou can try to run the following code to learn how to get screen height and width −Live Demo                    document.write("Screen width: " + screen.width);          document.write("Screen width: " + screen.width);          

What is availHeight Property in JavaScript

karthikeya Boyini
Updated on 23-Jun-2020 08:03:15

88 Views

Use the screen.availHeight property to return the width of the user’s screen. The result will be in pixels and Taskbar feature won’t be included.ExampleYou can try to run the following code to learn how to work with the screen.availHeight property in JavaScript −Live Demo                    document.write("Height of the screen: "+screen.availHeight);          

Role of source RegExp Property in JavaScript

Akshaya Akki
Updated on 23-Jun-2020 08:02:06

160 Views

The source RegExp property in JavaScript is a read-only string property of RegExp objects. It contains the text of the RegExp pattern. This text does not include the delimiting slashes used in regular-expression literals, and it does not include the "g", "i", and "m" attributes.ExampleYou can try to run the following code to learn how to implement source RegExp property in JavaScript −           JavaScript RegExp source Property                        var str = "JavaScript is an interesting scripting language";          var re = new RegExp( "script", "g" );          re.test(str);                    document.write("The regular expression is : " + re.source);          

Role of the Window History Object in JavaScript

Paul Richard
Updated on 23-Jun-2020 08:00:51

231 Views

The window.history object is used to go back or to the next page of the web browser. It has the browser's history and comes with the following two methods −history.back − Go to previous URLhistory.next − Go to next URLExampleYou can try to run the following code to learn how to work with window.history object in JavaScript −Live Demo                    function backPage() {             window.history.back()          }          function nextPage() {             window.history.next()          }                      

Negate Positive Elements of an Integer Array in C#

Chandu yadav
Updated on 23-Jun-2020 08:00:23

418 Views

The following is the array and its elements −int[] arr = { 10, 20, 15 };Set negative value to positive elements.if (arr[i] > 0) arr[i] = -arr[i];Loop the above until the length of the array.for (int i = 0; i < arr.Length; i++) {    Console.WriteLine(arr[i]);    if (arr[i] > 0)    arr[i] = -arr[i]; }Let us see the complete example.Example Live Demousing System; public class Demo {    public static void Main(string[] args) {       int[] arr = { 10, 20, 15 };       Console.WriteLine("Displaying elements...");       for (int i = 0; i < ... Read More

Return Time Portion of Date as Human-Readable String

Sai Nath
Updated on 23-Jun-2020 08:00:07

109 Views

To return the “time” portion of the Date as a human-readable string, use the toTimeString() method in JavaScript. This method returns the time portion of a Date object in the human-readable form.ExampleYou need to run the following code to return only the time portion of a Date −           JavaScript toTimeString Method                        var dateobject = new Date(2018, 0, 1, 14, 39, 7);          document.write( dateobject.toTimeString() );          

Advertisements