Add Node at First Position in a Linked List Using C#

Chandu yadav
Updated on 23-Jun-2020 07:10:46

451 Views

Firstly, set a LinkedList with nodes.string [] students = {"Tim", "Jack", "Henry", "David", "Tom"}; LinkedList list = new LinkedList(students);To add a node at the first position, use the AddFirst() method.list.AddFirst("Amit");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       Console.WriteLine("LinkedList after adding a node at the first position...");   ... Read More

Get Smallest and Largest Element from a List in C#

George John
Updated on 23-Jun-2020 07:09:34

10K+ Views

Set a list.List list = new List { 150, 300, 400, 350, 450, 550, 600 };To get the smallest element, use the Min() method.list.AsQueryable().Min();To get the largest element, use the Max() method.list.AsQueryable().Max();Let us see the complete code −Example Live Demousing System; using System.Collections.Generic; using System.Linq; class Demo {    static void Main() {       List list = new List { 150, 300, 400, 350, 450, 550, 600 };       foreach(long ele in list){          Console.WriteLine(ele);       }       // getting largest element       long max_num = list.AsQueryable().Max(); ... Read More

Return Total Elements in a Sequence as 64-bit Signed Integer in C#

karthikeya Boyini
Updated on 23-Jun-2020 07:08:30

116 Views

Firstly, set a string array.string[] num = { "One", "Two", "Three", "Four", "Five"};Use the Linq LongCount method to get the count of elements.num.AsQueryable().LongCount();Here is the complete code −Example Live Demousing System; using System.Collections.Generic; using System.Linq; class Demo {    static void Main() {       string[] num = { "One", "Two", "Three", "Four", "Five"};       long res = num.AsQueryable().LongCount();       Console.WriteLine("{0} elements", res);    } }Output5 elements

General Date and Long Time G Format Specifier in C#

Samual Sam
Updated on 23-Jun-2020 07:07:32

284 Views

The General Date Long Time standard format specifier is a combination of the short date ("d") and long time ("T") patterns, separated by a space.Set the date −DateTime dt = new DateTime(2018, 1, 3, 3, 45, 20);Now, use the ToString() method and DateTimeFormatInfo.dt.ToString("G", DateTimeFormatInfo.InvariantInfo)Example Live Demousing System; using System.Globalization; class Demo {    static void Main() {       DateTime dt = new DateTime(2018, 1, 3, 3, 45, 20);       Console.WriteLine(dt.ToString("G",       DateTimeFormatInfo.InvariantInfo));    } }Output01/03/2018 03:45:20

Access Document Properties Using W3C DOM Method

Sravani S
Updated on 23-Jun-2020 07:06:52

191 Views

This IE4 document object model (DOM) introduced in Version 4 of Microsoft's Internet Explorer browser. IE 5 and later versions include support for most basic W3C DOM features.ExampleTo access document properties using W3C DOM method, you can try to run the following code −           Document Title                                     This is main title       Click the following to see the result:                                                          

Object Initializer in C#

karthikeya Boyini
Updated on 23-Jun-2020 07:06:25

196 Views

Initialize an object of a class with object initialize.Using it, you can assign values to the fields at the time of creating an object.We created Employee object and assigned values using curly bracket at the same time.Employee empDetails = new Employee() {    EID = 10,    EmpName = "Tim",    EmpDept = "Finance" }Now access the values of the Employee class. For example, for name of the employee.empDetails.EmpNameLet us see the complete code −Example Live Demousing System; public class Demo {    public static void Main() {       Employee empDetails = new Employee() {         ... Read More

Get List of Document Properties Accessible Using W3C DOM

Ramu Prasad
Updated on 23-Jun-2020 07:06:10

246 Views

The following are the document properties which can be accessed using W3C DOM −Sr.NoProperty & Description1BodyA reference to the Element object that represents the tag of this document.Ex − document.body2DefaultViewIts Read-only property and represents the window in which the document is displayed.Ex − document.defaultView3DocumentElementA read-only reference to the tag of the document.Ex − document.documentElement8/31/20084ImplementationIt is a read-only property and represents the DOMImplementation object that represents the implementation that created this document.Ex − document.implementation

Month M M Format Specifier in C#

Arjun Thakur
Updated on 23-Jun-2020 07:05:26

364 Views

The Month standard format specifier represents a custom date and time format string.The format string is defined by the current DateTimeFormatInfo.MonthDayPattern property.The custom format string −MMMM ddExample Live Demousing System; using System.Globalization; class Demo {    static void Main() {       DateTime date = new DateTime(2018, 6, 11, 9, 15, 0);       Console.WriteLine(date.ToString("m", CultureInfo.CreateSpecificCulture("en-us")));    } }OutputJune 11

Collection Initialization in C#

Ankith Reddy
Updated on 23-Jun-2020 07:04:32

910 Views

Initialize Collection like class objects using collection initializer syntax.Firstly, set values for the Employee object −var emp1 = new Employee() { EID = 001, EmpName = "Tim", EmpDept = "Finance"}; var emp2 = new Employee() { EID = 002, EmpName = "Tom", EmpDept = "HR"};Now add this under a collection.IList empDetails = new List {emp1, emp2 };Let us see the complete code −Example Live Demousing System; using System.Collections.Generic; public class Demo {    public static void Main() {       var emp1 = new Employee() { EID = 001, EmpName = "Tim", EmpDept = "Finance"};       var emp2 ... Read More

Turn On Error Information in Your Web Browser

Nishtha Thakur
Updated on 23-Jun-2020 07:04:14

390 Views

The most basic way to track down errors is by turning on error information in your browser. By default, Internet Explorer shows an error icon in the status bar when an error occurs on the page.Double-clicking this icon takes you to a dialog box showing information about the specific error that occurred.Since this icon is easy to overlook, Internet Explorer gives you the option to automatically show the Error dialog box whenever an error occurs.To enable this option, select Tools → Internet Options → Advanced tab. and then finally check the "Display a Notification About Every Script Error" box option ... Read More

Advertisements