Programming Articles

Page 811 of 2547

C# Currency ("C") Format Specifier

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

The C format specifier (currency) is used to format numeric values as currency amounts. It automatically applies the appropriate currency symbol, decimal places, and thousands separators based on the current culture settings. Syntax Following is the syntax for using the currency format specifier − value.ToString("C") // Default currency format value.ToString("C3") // Currency with 3 decimal places value.ToString("C", culture) // Currency with specific culture The precision specifier (optional number after C) determines how many decimal ...

Read More

Byte.MaxValue Field in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 358 Views

The Byte.MaxValue field in C# represents the largest possible value that can be stored in a byte data type. Since a byte is an 8-bit unsigned integer, it can hold values from 0 to 255, making Byte.MaxValue equal to 255. This constant field is particularly useful when you need to validate input ranges, initialize arrays with maximum values, or perform boundary checks in your applications. Syntax Following is the syntax for the Byte.MaxValue field − public const byte MaxValue = 255; Using Byte.MaxValue for Range Validation Example using System; ...

Read More

Addition and Concatenation in C#

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 418 Views

In C#, addition refers to mathematical operations with numeric types, while concatenation refers to joining strings together. The + operator can perform both operations depending on the operand types, and C# provides several methods for string concatenation. Syntax Following is the syntax for numeric addition − int result = number1 + number2; Following is the syntax for string concatenation using the + operator − string result = string1 + string2; Following is the syntax for string concatenation using String.Concat() method − string result = String.Concat(string1, string2); ...

Read More

What are integer literals in C#?

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

An integer literal in C# is a constant numeric value written directly in the code. Integer literals can be decimal (base 10) or hexadecimal (base 16) constants. A prefix specifies the base: 0x or 0X for hexadecimal, with no prefix for decimal. They can also have suffixes like U for unsigned and L for long. Syntax Following is the syntax for different types of integer literals − // Decimal literals 123 200L // long 456U // unsigned int 789UL // unsigned long // Hexadecimal literals 0xFF ...

Read More

How to swap two numbers without using a temp variable in C#

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 938 Views

Swapping two numbers without using a temporary variable can be achieved using different techniques in C#. These methods eliminate the need for extra memory allocation and demonstrate clever mathematical and bitwise operations. Using Arithmetic Operations The most common approach uses addition and subtraction operations to swap values − val1 = val1 + val2; val2 = val1 - val2; val1 = val1 - val2; Example using System; class Program { static void Main(string[] args) { int val1, val2; ...

Read More

How to convert a string into int in C#?

George John
George John
Updated on 17-Mar-2026 441 Views

Converting a string to an integer in C# is a common task that can be accomplished using several methods. The most straightforward approach is using Int32.Parse() method, which converts the string representation of a number to its 32-bit signed integer equivalent. Syntax Following is the syntax for using Int32.Parse() method − int result = Int32.Parse(stringValue); Following is the syntax for using Convert.ToInt32() method − int result = Convert.ToInt32(stringValue); Following is the syntax for using int.TryParse() method − bool success = int.TryParse(stringValue, out int result); Using Int32.Parse() ...

Read More

C# program to display the next day

Ankith Reddy
Ankith Reddy
Updated on 17-Mar-2026 3K+ Views

To display the next day in C#, use the AddDays() method with a value of 1. The AddDays() method adds or subtracts days from a DateTime object and returns a new DateTime representing the modified date. Syntax Following is the syntax for using AddDays() method − DateTime.AddDays(double value) Parameters value − A number of whole and fractional days. Use positive values for future dates and negative values for past dates. Return Value The method returns a new DateTime object that represents the date and time with the ...

Read More

Remove an item from a Hashtable in C#

Ankith Reddy
Ankith Reddy
Updated on 17-Mar-2026 826 Views

The Hashtable class in C# provides the Remove() method to delete key-value pairs. The method takes the key as a parameter and removes the corresponding entry from the hashtable if it exists. Syntax Following is the syntax for removing an item from a Hashtable − hashtable.Remove(key); Parameters key − The key of the element to remove from the hashtable. Return Value The Remove()

Read More

What are Base and Derived Classes in C#?

Chandu yadav
Chandu yadav
Updated on 17-Mar-2026 363 Views

In C# object-oriented programming, inheritance allows you to create new classes based on existing ones. A base class (also called parent class) is the original class that provides common properties and methods. A derived class (also called child class) inherits from the base class and can access its members while adding its own specific functionality. The derived class automatically inherits all accessible members from the base class, including fields, properties, and methods, promoting code reusability and establishing an "is-a" relationship. Syntax Following is the syntax for creating a derived class in C# − class BaseClass ...

Read More

Math.Log10() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 448 Views

The Math.Log10() method in C# calculates the base-10 logarithm of a specified number. This method is particularly useful in mathematical calculations, scientific computations, and when working with exponential data that needs to be converted to a logarithmic scale. Syntax Following is the syntax for the Math.Log10() method − public static double Log10(double d); Parameters d − A double-precision floating-point number whose base-10 logarithm is to be found. Return Value The Log10() method returns different values based on the input parameter − Input Parameter (d) Return Value ...

Read More
Showing 8101–8110 of 25,466 articles
« Prev 1 809 810 811 812 813 2547 Next »
Advertisements