Samual Sam has Published 2492 Articles

C# Currency ("C") Format Specifier

Samual Sam

Samual Sam

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

27K+ 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

158 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

146 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

1K+ 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

302 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

1K+ 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

3K+ 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

Implicit conversion from Int16 to Decimal in C#

Samual Sam

Samual Sam

Updated on 23-Jun-2020 07:42:46

161 Views

The short type represents a 16-bit signed integer i.e. Int16.To implicitly convert a 16-bit signed integer to a Decimal, firstly set a short value.short val = -32768;To convert short to decimal, assign the value.dec = val;Let us see another example.Example Live Demousing System; public class Demo {    public static void ... Read More

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

Samual Sam

Samual Sam

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

3K+ 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 ... Read More

C# String.PadLeft Method

Samual Sam

Samual Sam

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

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

Advertisements