Programming Articles

Page 848 of 2547

Represent Int64 as a Hexadecimal String in C#

Chandu yadav
Chandu yadav
Updated on 17-Mar-2026 2K+ Views

To represent Int64 as a hexadecimal string in C#, use the Convert.ToString() method and set the base as 16 for hexadecimal conversion. Int64 represents a 64-bit signed integer that can hold values from -9, 223, 372, 036, 854, 775, 808 to 9, 223, 372, 036, 854, 775, 807. Syntax Following is the syntax for converting Int64 to hexadecimal string − Convert.ToString(longValue, 16) You can also use the ToString() method with format specifiers − longValue.ToString("X") // Uppercase hex longValue.ToString("x") // Lowercase hex Using Convert.ToString() Method The ...

Read More

DateTime.ToLongTimeString() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 1K+ Views

The DateTime.ToLongTimeString() method in C# is used to convert the value of the current DateTime object to its equivalent long time string representation. This method formats the time portion of a DateTime object according to the current culture's long time format pattern. Syntax Following is the syntax − public string ToLongTimeString(); Return Value Returns a string that contains the long time string representation of the current DateTime object, formatted according to the current culture's long time pattern. Using ToLongTimeString() with Current DateTime The method uses the current system culture to determine ...

Read More

The "0" custom format specifier in C#

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 2K+ Views

The "0" custom format specifier in C# is a zero placeholder that ensures a digit appears in each specified position. If the value being formatted has a digit in that position, it displays the digit; otherwise, it displays a zero. This format specifier is particularly useful for creating fixed-width numeric displays, padding numbers with leading zeros, or ensuring decimal places are always shown. Syntax Following is the syntax for using the "0" custom format specifier − number.ToString("000") // For integers with leading zeros number.ToString("0.00") // For decimals with ...

Read More

C# program to count upper and lower case characters in a given string

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 1K+ Views

To count uppercase and lowercase characters in a string, we can iterate through each character and check if it falls within specific ASCII ranges. For uppercase letters, we check if the character is between 'A' and 'Z', while for lowercase letters, we check if it's between 'a' and 'z'. Syntax Following is the syntax for checking uppercase characters − if (myStr[i] >= 'A' && myStr[i] = 'a' && myStr[i] = 'a' && myStr[i] = 'A' && myStr[i]

Read More

Abort in C#

Samual Sam
Samual Sam
Updated on 17-Mar-2026 817 Views

The Thread.Abort() method in C# is used to forcibly terminate a thread by throwing a ThreadAbortException. This method was commonly used in older versions of .NET Framework but is now deprecated and not supported in .NET Core and .NET 5+. Important Note: Thread.Abort() is considered unsafe and unreliable. Modern C# applications should use cooperative cancellation with CancellationToken instead. Syntax Following is the syntax for using Thread.Abort() − thread.Abort(); The method throws a ThreadAbortException that can be caught, but the thread will still terminate − try { // thread ...

Read More

How to insert an item into a C# list by using an index?

George John
George John
Updated on 17-Mar-2026 3K+ Views

The Insert() method in C# allows you to add an item to a List at a specific index position. This method shifts existing elements to make room for the new item, automatically increasing the list's size. Syntax Following is the syntax for the Insert() method − list.Insert(index, item); Parameters index − The zero-based index at which the item should be inserted. item − The object to insert into the list. How It Works When you use Insert(), the method shifts all elements at and after ...

Read More

The "#" custom specifier in C#

Arjun Thakur
Arjun Thakur
Updated on 17-Mar-2026 274 Views

The # custom format specifier in C# serves as a digit placeholder symbol in numeric formatting. It displays a digit only if one exists at that position, making it useful for creating flexible number formats that suppress unnecessary leading and trailing zeros. Syntax Following is the syntax for using the # format specifier − number.ToString("#formatPattern") String.Format("{0:#formatPattern}", number) How It Works When formatting a number, the # symbol represents an optional digit position. If the value has a digit at that position, it displays the digit. If not, nothing is displayed for that position. ...

Read More

C# program to find node in Linked List

Samual Sam
Samual Sam
Updated on 17-Mar-2026 648 Views

The LinkedList class in C# provides methods to search for nodes within the list. The Find() method returns the first LinkedListNode that contains the specified value, or null if the value is not found. Syntax Following is the syntax for finding a node in a LinkedList − LinkedListNode node = linkedList.Find(value); Following is the syntax for finding the last occurrence of a node − LinkedListNode node = linkedList.FindLast(value); Return Value The Find() method returns a LinkedListNode object containing the value, or null if the value is not found. The ...

Read More

What are static members of a C# Class?

Samual Sam
Samual Sam
Updated on 17-Mar-2026 5K+ Views

Static members in C# belong to the class itself rather than to any specific instance of the class. When you declare a member as static, only one copy exists regardless of how many objects are created from the class. Static members are accessed using the class name directly, without creating an instance. They are commonly used for utility functions, constants, and shared data that should be consistent across all instances of a class. Syntax Following is the syntax for declaring static members − public static dataType memberName; public static returnType MethodName() { ...

Read More

List down a list of the escape characters in C#

Arjun Thakur
Arjun Thakur
Updated on 17-Mar-2026 1K+ Views

Escape characters in C# are special character sequences that begin with a backslash (\) and represent characters that cannot be directly typed or displayed. They are commonly used in strings, regular expressions, and character literals to represent control characters, special symbols, and Unicode characters. Common Escape Characters The most frequently used escape characters include for new lines, \t for tabs, and " for quotes within strings. Example using System; class Program { static void Main() { Console.WriteLine("Hello\tWorld"); ...

Read More
Showing 8471–8480 of 25,466 articles
« Prev 1 846 847 848 849 850 2547 Next »
Advertisements