Return String Representing Source for Equivalent Date Object

Daniol Thomas
Updated on 23-Jun-2020 08:07:54

122 Views

To return a string representing the source for an equivalent Date object, use the JavaScript toSource() method. This method returns a string representing the source code of the object.ExampleYou can try to run the following code to return a string representing the source for an equivalent Date object −           JavaScript toSource() Method                        var dt = new Date(2018, 0, 15, 14, 39, 7);          document.write( "Formated Date : " + dt.toSource() );          

Short Date 'd' Format Specifier

Samual Sam
Updated on 23-Jun-2020 08:07:54

306 Views

The "d" format specifier represents a custom date and time format string.The format string is defined by culture's DateTimeFormatInfo.ShortDatePattern property.The custom format string is −MM/dd/yyyyExample Live Demousing System; using System.Globalization; class Demo {    static void Main() {       DateTime myDate = new DateTime(2018,9, 09);       Console.WriteLine(myDate.ToString("d", DateTimeFormatInfo.InvariantInfo));       Console.WriteLine(myDate.ToString("d", CultureInfo.CreateSpecificCulture("en-US")));    } }Output09/09/2018 9/9/2018

Set Minutes for a Specified Date According to Universal Time

Alankritha Ammu
Updated on 23-Jun-2020 08:07:23

154 Views

JavaScript date setUTCMinutes() method sets the minutes for a specified date according to universal time.The following are the parameters for setUTCMinutes(minutesValue[, secondsValue[, msValue]]) method −minutesValue − An integer between 0 and 59, representing the minutes.secondsValue − An integer between 0 and 59, representing the seconds. If you specify the secondsValue parameter, you must also specify the minutesValue.msValue − A number between 0 and 999, representing the milliseconds. If you specify the msValue parameter, you must also specify the minutesValue and secondsValue.ExampleYou can try to run the following code to set the minutes for a specified date according to universal time ... Read More

C# Enum Parse Method

Ankith Reddy
Updated on 23-Jun-2020 08:07:12

2K+ Views

The Parse method in Enum converts the string representation of the name or numeric value of enum constants to an equivalent enumerated object.The following is our enumeration.enum Vehicle { Car, Bus, Truck, Motobike };Now, use the GetNames() method in a loop to get the enum values. Parse them using the Enum.Parse() method as shown below −Enum.Parse(typeof(Vehicle)Example Live Demousing System; public class Demo {    enum Vehicle { Car, Bus, Truck, Motobike };    public static void Main() {       Console.WriteLine("The enumeration...");       foreach (string v in Enum.GetNames(typeof(Vehicle))) {          Console.WriteLine("{0} = {1:D}", v, Enum.Parse(typeof(Vehicle), ... Read More

Set Month for Specified Date According to Universal Time

Rishi Rathor
Updated on 23-Jun-2020 08:06:35

115 Views

JavaScript date setUTCMonth ( ) method sets the month for a specified date according to universal time.The following is the parameter of setUTCMonth ( monthvalue ) method in JavaScript −monthValue − An integer between 0 and 11, representing the month.ExampleYou can try to run the following code to set the month for a specified date according to universal time −           JavaScript getUTCSeconds Method                        var dt = new Date( "Aug 28, 2008 13:30:00" );          dt.setUTCMonth( 2 );                    document.write( dt );          

C# Enum ToString Method

karthikeya Boyini
Updated on 23-Jun-2020 08:06:27

3K+ Views

The ToString() method converts the value of this instance to its equivalent string representation.Firstly, set an enum.enum Vehicle { Car, Bus, Truck, Motobike };To convert it to an equivalent string representation, use ToString().Vehicle.Car.ToString("d")Example Live Demousing System; public class Demo {    enum Vehicle { Car, Bus, Truck, Motobike };    public static void Main() {       Console.WriteLine("Vehicle.Car = {0}", Vehicle.Car.ToString("d"));       Console.WriteLine("Vehicle.Bus = {0}", Vehicle.Bus.ToString("d"));    } }OutputVehicle.Car = 0 Vehicle.Bus = 1

The Custom Specifier in C#

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

178 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

176 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

221 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

859 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);          

Advertisements