Server Side Programming Articles

Page 815 of 2109

C# Program to get information about a file

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

To get information about a file means to retrieve the attributes and properties associated with that particular file. File attributes indicate characteristics such as whether a file is normal, hidden, archived, read-only, or a system file. In C#, the FileInfo class provides comprehensive information about files, including attributes, size, creation time, and modification time. Syntax Following is the syntax for creating a FileInfo object and getting file attributes − FileInfo info = new FileInfo("filename.txt"); FileAttributes attr = info.Attributes; Using FileInfo to Get File Attributes The FileAttributes enumeration represents various file attributes that ...

Read More

C# Program to get the last write time of a file

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

To get the last write time of a file in C#, you can use the LastWriteTime property of the FileInfo class. This property returns a DateTime object representing when the file was last modified. You can also use the static File.GetLastWriteTime() method as an alternative approach for retrieving the last write time without creating a FileInfo instance. Syntax Using FileInfo class − FileInfo fileInfo = new FileInfo("filename.txt"); DateTime lastWrite = fileInfo.LastWriteTime; Using File.GetLastWriteTime() method − DateTime lastWrite = File.GetLastWriteTime("filename.txt"); Using FileInfo Class The FileInfo class provides comprehensive file ...

Read More

C# Program to get the last access time of a file

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

To get the last access time of a file in C#, you can use the LastAccessTime property of the FileInfo class or the static File.GetLastAccessTime() method. The last access time represents when the file was last opened or read. Syntax Using the FileInfo class − FileInfo fileInfo = new FileInfo("filepath"); DateTime lastAccess = fileInfo.LastAccessTime; Using the static File.GetLastAccessTime() method − DateTime lastAccess = File.GetLastAccessTime("filepath"); Using FileInfo Class The FileInfo class provides an object-oriented approach to working with files. Here's how to get the last access time − ...

Read More

Get the creation time of a file in C#

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

To get the creation time of a file in C#, you can use the CreationTime property of the FileInfo class or the static methods from the File class. This allows you to retrieve when a file was originally created on the file system. Syntax Using the FileInfo class − FileInfo fileInfo = new FileInfo("filename.txt"); DateTime creationTime = fileInfo.CreationTime; Using the static File class − DateTime creationTime = File.GetCreationTime("filename.txt"); Using FileInfo Class The FileInfo class provides an object-oriented approach to work with file information. Create a FileInfo object and access ...

Read More

Lowercase suffixes in C#

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

In C#, lowercase suffixes are used with numeric literals to specify their data type explicitly. These suffixes tell the compiler to treat the literal as a specific numeric type rather than inferring the type automatically. Syntax Following are the common lowercase suffixes used with numeric literals − long number = 12345l; // l for long float number = 3.14f; // f for float uint number = 100u; // u for unsigned int ulong number = 500ul; ...

Read More

Literal number suffixes in C#

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

Literal number suffixes in C# are used to explicitly specify the data type of numeric literals. Without suffixes, the compiler infers the type based on the value, but suffixes ensure the literal is treated as a specific numeric type. These suffixes are particularly useful when working with method overloads, preventing ambiguous type conversions, and ensuring the correct data type is used for calculations. Syntax Following is the syntax for using literal number suffixes − dataType variable = numericValue + suffix; The suffix can be either uppercase or lowercase, but uppercase is recommended for ...

Read More

ElementAt() method in C#

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

The ElementAt() method in C# is a LINQ extension method that retrieves an element at a specified index from any collection that implements IEnumerable. It provides a way to access elements by index in collections that don't have built-in indexing support. Syntax Following is the syntax for the ElementAt() method − public static TSource ElementAt(this IEnumerable source, int index) Parameters source − The IEnumerable to return an element from. index − The zero-based index of the element to retrieve. Return Value Returns the element at the specified position in ...

Read More

C# Program to get the first three elements from a list

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

The Take() method in C# is a LINQ extension method used to retrieve a specified number of elements from the beginning of a collection. It returns an IEnumerable containing the first n elements from the original collection. Syntax Following is the syntax for using the Take() method − IEnumerable Take(int count) Parameters count − An integer specifying the number of elements to return from the start of the sequence. Return Value The Take() method returns an IEnumerable that contains the specified number of elements from the start ...

Read More

C# Program to display a string in reverse alphabetic order

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

To display a string in reverse order, you can convert the string to a character array and then use the Array.Reverse() method. This approach reverses the order of characters, displaying them from last to first. Syntax Following is the syntax for converting a string to character array − char[] arr = str.ToCharArray(); Following is the syntax for reversing the array − Array.Reverse(arr); Using Array.Reverse() Method The simplest approach is to convert the string to a character array and use Array.Reverse() to reverse the order of characters − ...

Read More

C# Program to split a string on spaces

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

In C#, the Split() method is used to divide a string into an array of substrings based on a specified delimiter. When splitting a string on spaces, we use the space character ' ' as the delimiter. Syntax Following is the syntax for splitting a string on spaces − string[] result = str.Split(' '); You can also use the overloaded version with options − string[] result = str.Split(' ', StringSplitOptions.RemoveEmptyEntries); Parameters separator − The character used to split the string (space character ' ' in this case). ...

Read More
Showing 8141–8150 of 21,090 articles
« Prev 1 813 814 815 816 817 2109 Next »
Advertisements