To match an expression, use the JavaScript match() method. This method is used to retrieve the matches when matching a string against a regular expression. The following is the parameter −param − A regular expression object.If the regular expression does not include the g flag, it returns the same result as regexp.exec(string).If the regular expression includes the g flag, the method returns an Array containing all the matches.ExampleYou can try to run the following code to math an expression using JavaScript Regular Expression − JavaScript String match() Method ... Read More
Set a LinkedList with nodes.string [] students = {"Tim", "Jack", "Henry", "David", "Tom"}; LinkedList list = new LinkedList(students);Now, use the AddLast() method to add a node at the last position.list.AddLast("Kevin");Here is the complete code with the updated LinkedList.Example Live Demousing System; using System.Collections.Generic; class Demo { static void Main() { string [] students = {"Tim", "Jack", "Henry", "David", "Tom"}; LinkedList list = new LinkedList(students); foreach (var stu in list) { Console.WriteLine(stu); } // adding a node at the end ... Read More
The operator is used in JavaScript to check whether a property is in an object or not.ExampleYou can try to run the following code to learn how to use in operator in JavaScript −Live Demo var emp = {name:"Amit", subject:"Java"}; document.write("name" in emp); document.write(""); document.write("subject" in emp); document.write(""); document.write("MAX_VALUE" in Number); document.write(""); document.write("MIN" in Number);
Use the Linq Average() method to find the average of a sequence of numeric values.Firstly, set a sequence.List list = new List { 5, 8, 13, 35, 67 };Now, use the Queryable Average() method to get the average.Queryable.Average(list.AsQueryable());Example Live Demousing System; using System.Linq; using System.Collections.Generic; class Demo { static void Main() { List list = new List { 5, 8, 13, 35, 67 }; double avg = Queryable.Average(list.AsQueryable()); Console.WriteLine("Average = "+avg); } }OutputAverage = 25.6
To find a character except for a newline, use the Metacharacter. (period). You can try to run the following code to find a character −Example JavaScript Regular Expression var myStr = "We provide websites! We provide content!"; var reg = /p.o/g; var match = myStr.match(reg); document.write(match);
Set query in a select clause using the into operator.The following is our list with Employee details −IList employee = new List() { new Employee() { EmpID = 1, EmpName = "Tom", EmpMarks = 90, Rank = 8} , new Employee() { EmpID = 2, EmpName = "Anne", EmpMarks = 60, Rank = 21 } , new Employee() { EmpID = 3, EmpName = "Jack", EmpMarks = 76, Rank = 18 } , new Employee() { EmpID = 4, EmpName = "Amy" , EmpMarks = 67, Rank = 20} , };Now, fetch employee name that ends ... Read More
Javascript date setUTCMilliseconds() method sets the milliseconds for a specified date according to universal time.The following is the parameter for setUTCMilliseconds(millisecondsValue) −millisecondsValue − A number between 0 and 999, representing the milliseconds.ExampleYou can try to run the following code to set the milliseconds for a specified date according to universal time − JavaScript setUTCMilliseconds Method var dt = new Date( "Aug 28, 2008 23:30:00" ); dt.setUTCMilliseconds( 1200 ); document.write( dt );
Use the BufferHeight gets or sets the height of the buffer area.Use the property like this −Console.BufferHeightLet us see the complete example.Example Live Demousing System; class Demo { static void Main() { Console.WriteLine("Buffer height (rows) = "+Console.BufferHeight); } }OutputBuffer height (rows) = 0
We have a list without any element.List val = new List { };To display the default and avoid any error, use the FirstorDefault() method.val.AsQueryable().FirstOrDefault();You can also change the value to be displayed as default.Let us see the code.Example Live Demousing System; using System.Collections.Generic; using System.Linq; class Demo { static void Main() { List val = new List{ }; float a = val.AsQueryable().FirstOrDefault(); Console.WriteLine("Default Value = "+a); if (a == 0.0f) { a = 0.1f; } Console.WriteLine("Default Float value updated = "+a); } }OutputDefault Value = 0 Default Float value updated = 0.1
TimeSpan Seconds() is part of time, whereas TimeSpan TotalSeconds() converts entire time to seconds.Let us first see the TimeSpan Seconds() method.Example Live Demousing System; using System.Linq; public class Demo { public static void Main() { TimeSpan ts = new TimeSpan(0, 100, 0, 20, 0); // seconds Console.WriteLine(ts.Seconds); } }Output20Now, let us see how TotalSeconds works for the same TimeSpan value.Example Live Demousing System; using System.Linq; public class Demo { public static void Main() { TimeSpan ts = new TimeSpan(0, 100, 0, 20, 0); // ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP