C# Program to add a node at the last position in a Linked List

karthikeya Boyini
Updated on 23-Jun-2020 07:41:13

124 Views

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

What is the usage of in operator in JavaScript?

Arushi
Updated on 23-Jun-2020 07:41:06

59 Views

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

C# Program to find the average of a sequence of numeric values

Samual Sam
Updated on 23-Jun-2020 07:40:42

2K+ Views

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

With JavaScript RegExp find a character except newline?

Anvi Jain
Updated on 23-Jun-2020 07:40:33

123 Views

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

C# into keyword

Ankith Reddy
Updated on 23-Jun-2020 07:40:16

62 Views

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

What is the role of Navigator object in JavaScript?

Rama Giri
Updated on 23-Jun-2020 07:40:04

205 Views

To get information about the browser your webpage is currently running in, use the built-in navigator object. You can use various Navigator methods and properties with the object.ExampleYou can try to run the following code to implement Navigator object in JavaScript −           Navigator Object Example                                  

Set the milliseconds for a specified date according to universal time.

Nishtha Thakur
Updated on 23-Jun-2020 07:38:52

111 Views

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

C# Console BufferHeight Property

Chandu yadav
Updated on 23-Jun-2020 07:38:38

61 Views

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

C# String.PadLeft Method

Samual Sam
Updated on 23-Jun-2020 07:38:19

194 Views

Pad the beginning of the string with spaces using the PadLeft() method. You can also pad it with a Unicode character.Let’s say the following is our string.string myStr = "DemoOne";To set a padding at the beginning of the above string, use the PadLeft method.myStr.PadLeft(10);Here is the complete example.Example Live Demousing System; class Demo {    static void Main() {       string myStr = "DemoOne";       // set padding at the beginning       Console.WriteLine(myStr.PadLeft(10));       myStr = "DemoTWO";       // set padding at the beginning       Console.Write(myStr.PadLeft(15));    } }OutputDemoOne DemoTWO

Display the default if element is not found in a C# List

George John
Updated on 23-Jun-2020 07:37:32

23 Views

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

Advertisements