Samual Sam has Published 1776 Articles

C# Program to access first element in a Dictionary

Samual Sam

Samual Sam

Updated on 23-Jun-2020 08:09:48

5K+ Views

The following is our Dictionary with some elements −Dictionary d = new Dictionary() {    {1, "Electronics"},    {2, "Clothing"},    {3, "Toys"},    {4, "Footwear"},    {5, "Accessories"} };Now to display the first element, set the key like this.d[1];The above displays the first element.Example Live Demousing System; using System.Collections.Generic; public ... Read More

Short Date ("d") Format Specifier

Samual Sam

Samual Sam

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

323 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);       ... Read More

The "%" custom specifier in C#

Samual Sam

Samual Sam

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

184 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.##%", ... Read More

C# Currency ("C") Format Specifier

Samual Sam

Samual Sam

Updated on 23-Jun-2020 07:58:36

33K+ Views

The "C" (or currency) format specifier is used to convert a number to a string representing a currency amount.Let us see an example.double value = 139.87;Now to display the above number until three decimal places, use (“C3”) currency format specifier.value.ToString("C3", CultureInfo.CurrentCulture)Let us see another example.Example Live Demousing System; using System.Globalization; class ... Read More

What is the role of pageXOffset property in JavaScript?

Samual Sam

Samual Sam

Updated on 23-Jun-2020 07:56:50

288 Views

If you want to get the pixels the document scrolled to from the upper left corner of the window, then use the pageXoffset and pageYoffset property. Use pageXoffset for horizontal pixels.ExampleYou can try to run the following code to learn how to work with pageXOffset property in JavaScript −Live Demo ... Read More

C# Program to remove a node at the beginning of a Linked List

Samual Sam

Samual Sam

Updated on 23-Jun-2020 07:53:38

232 Views

To remove a node at the beginning of a LinkedList, use the RemoveFirst() method.string [] employees = {"Peter", "Robert", "John", "Jacob"}; LinkedList list = new LinkedList(employees);Now, to remove the first element, use the RemoveFirst() method.list.RemoveFirst();Let us see the complete example.Example Live Demousing System; using System.Collections.Generic; class Demo {    static void ... Read More

C# Program to rename a file

Samual Sam

Samual Sam

Updated on 23-Jun-2020 07:51:35

2K+ Views

Use the Move method to rename a file.Let’s say the file name is −D:\tom.txtNow, to update it to the following, use the Move() method.D:\tim.txtLet us see the complete code.Exampleusing System; using System.IO; public class Demo {    public static void Main() {       File.Move(@"D:\tom.txt", @"D:\tim.txt");       ... Read More

Implicit conversion from UInt64 to Decimal in C#

Samual Sam

Samual Sam

Updated on 23-Jun-2020 07:48:53

467 Views

The ulong type represents a 64-bit unsigned integer i.e. UInt64.To implicitly convert a 64-bit unsigned integer to a Decimal, firstly set UInt64 value.ulong val = ulong.MaxValue;To convert ulong to decimal, assign the value.decimal dec; dec = val;Let us see the above example.Example Live Demousing System; public class Demo {    public ... Read More

LinkedList Remove method in C#

Samual Sam

Samual Sam

Updated on 23-Jun-2020 07:47:23

2K+ Views

Use the Remove() method to remove the first occurrence of a node in a LinkedList.Firstly, let us set a LinkedList with integer elements.int [] num = {2, 5, 7, 15}; LinkedList list = new LinkedList(num);Now, let’s say you need to remove node with element 7. For that, use the Remove() ... Read More

Represent Int32 as a Hexadecimal String in C#

Samual Sam

Samual Sam

Updated on 23-Jun-2020 07:44:35

5K+ Views

To represent Int32 as a Hexadecimal string in C#, use the ToString() method and set the base as the ToString() method’s second parameter i.e. 16 for Hexadecimal.Int32 represents a 32-bit signed integer.Firstly, set an Int32 variable.int val = 9898;Now, convert it to a hexadecimal string by including 16 as the ... Read More

Advertisements