Server Side Programming Articles

Page 823 of 2109

Delete a file in C#

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

In C#, you can use the File.Delete() method from the System.IO namespace to delete files from the file system. This method permanently removes the specified file if it exists. Syntax Following is the syntax for deleting a file − File.Delete(string path); Parameters path − A string specifying the path of the file to be deleted. This can be a relative or absolute path. Using File.Delete() Method The File.Delete() method removes the file at the specified path. If the file does not exist, the method does not throw an exception ...

Read More

The "E" and "e" custom specifiers in C#

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

The "E" and "e" custom specifiers in C# are used to format numbers in scientific notation (exponential notation). When any of these specifiers appear in a format string followed by at least one zero, the number is formatted with an "E" or "e" separator between the mantissa and the exponent. Syntax The following format specifiers create exponential notation − "E0" // Uppercase E with minimum exponent digits "e0" // Lowercase e with minimum exponent digits "E+0" // Uppercase E with explicit + sign "e+0" // Lowercase ...

Read More

C# Program to read all the lines of a file at once

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

The File.ReadAllText() method in C# reads all the text from a file and returns it as a single string. This method is part of the System.IO namespace and provides a simple way to read entire file contents at once. When you need to read all lines from a text file in one operation, ReadAllText() is more efficient than reading line by line, especially for smaller files. Syntax Following is the syntax for the File.ReadAllText() method − public static string ReadAllText(string path); Parameters path − The file path to read from. Can ...

Read More

Long Time ("T") Format Specifier in C#

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

The Long Time ("T") format specifier in C# is a standard date and time format specifier that displays the time portion of a DateTime value in a long format. This format is culture-sensitive and displays the full time representation including hours, minutes, seconds, and AM/PM designator where applicable. The "T" format specifier is defined by the DateTimeFormatInfo.LongTimePattern property and typically follows the pattern HH:mm:ss for 24-hour format or includes AM/PM for 12-hour format, depending on the culture. Syntax Following is the syntax for using the Long Time format specifier − dateTime.ToString("T") dateTime.ToString("T", CultureInfo.CreateSpecificCulture("culture-name")) ...

Read More

Full Date Short Time ("f") Format Specifier in C#

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

The Full Date Short Time ("f") format specifier in C# represents a combination of the long date ("D") and short time ("t") patterns. It displays the complete date information along with hours and minutes in a readable format. This format specifier is culture-sensitive and will display dates according to the specified culture's formatting conventions. Syntax Following is the syntax for using the "f" format specifier − DateTime.ToString("f") DateTime.ToString("f", CultureInfo.CreateSpecificCulture("culture-code")) Using "f" Format Specifier with Default Culture Example using System; class Demo { static void Main() { ...

Read More

Convert.ToSingle Method in C#

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

The Convert.ToSingle() method in C# converts a specified value to a single-precision floating-point number (float). This method can convert various data types including boolean, integer, string, and other numeric types to a 32-bit floating-point representation. Syntax Following is the syntax for the Convert.ToSingle() method − public static float ToSingle(object value); public static float ToSingle(bool value); public static float ToSingle(int value); public static float ToSingle(string value); Parameters value − The value to be converted to a single-precision floating-point number. Can be of various types including bool, int, string, double, decimal, etc. ...

Read More

C# DateTime to add days to the current date

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

The DateTime class in C# provides the AddDays() method to add a specified number of days to a date. This method is commonly used to calculate future dates from the current date or any given date. Syntax Following is the syntax for using AddDays() method − DateTime newDate = dateTime.AddDays(numberOfDays); Parameters The AddDays() method accepts the following parameter − numberOfDays − A double value representing the number of days to add. This can be positive (future dates) or negative (past dates). Return Value The method returns a new ...

Read More

C# Program to skip elements from a sequence as long as the specified condition is true

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

The SkipWhile() method in C# is a LINQ extension method that skips elements from the beginning of a sequence as long as a specified condition remains true. Once the condition becomes false, it returns all remaining elements including the first element that failed the condition. Syntax Following is the syntax for the SkipWhile() method − public static IEnumerable SkipWhile( this IEnumerable source, Func predicate ) Parameters source − The sequence of elements to skip from. predicate − A function to ...

Read More

Implicit conversion from 64-bit signed integer (long) to Decimal in C#

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

The long type represents a 64-bit signed integer in C#. C# allows implicit conversion from long to decimal because no data loss occurs during this conversion. The decimal type can accommodate all possible long values while providing higher precision. Syntax Following is the syntax for implicit conversion from long to decimal − long longValue = 123456789; decimal decimalValue = longValue; // Implicit conversion How It Works The conversion happens automatically because the decimal type has a wider range and higher precision than long. The decimal type can represent all integer values that ...

Read More

C# Exponential ("E") Format Specifier

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

The Exponential ("E") format specifier in C# converts a number to scientific notation. It represents numbers in the form of a coefficient multiplied by a power of 10, making it ideal for very large or very small numbers. Syntax The exponential format specifier has the following syntax − "E" or "e" "En" or "en" (where n specifies decimal places) The resulting string format is − "-d.ddd...E+ddd" or "-d.ddd...e+ddd" Where "d" represents a digit (0-9). The "E" or "e" separates the coefficient from the exponent. Exponential ...

Read More
Showing 8221–8230 of 21,090 articles
« Prev 1 821 822 823 824 825 2109 Next »
Advertisements