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() );
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
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
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
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 );
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
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%
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 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
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);
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP