Server Side Programming Articles

Page 822 of 2109

Month ("M", "m") Format Specifier in C#

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

The Month ("M", "m") format specifier in C# represents a custom date and time format string that displays the month and day portions of a date. This format specifier is defined by the current DateTimeFormatInfo.MonthDayPattern property and typically follows the pattern MMMM dd. Syntax Following is the syntax for using the Month format specifier − dateTime.ToString("M") dateTime.ToString("m") The custom format string pattern is − MMMM dd Using Month Format Specifier Basic Example using System; using System.Globalization; class Demo { static void Main() ...

Read More

Short Time ("t") Format Specifier in C#

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

The Short Time format specifier ("t") in C# is a standard date and time format specifier that displays only the time portion of a DateTime in a short format. It excludes the date and seconds, showing only hours and minutes along with the AM/PM designator for 12-hour formats. The "t" format specifier is defined by the DateTimeFormatInfo.ShortTimePattern property of the current culture. Different cultures may display the time differently based on their regional settings. Syntax Following is the syntax for using the short time format specifier − DateTime.ToString("t") DateTime.ToString("t", CultureInfo) The underlying custom ...

Read More

Collection Initialization in C#

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

Collection initialization in C# allows you to initialize collections with values at the time of creation using a concise syntax. This feature, introduced in C# 3.0, makes code more readable and eliminates the need for multiple Add() method calls. Collection initializers work with any collection type that implements IEnumerable and has an Add method, including List, Dictionary, arrays, and custom collections. Syntax Following is the syntax for collection initialization − CollectionType collectionName = new CollectionType { item1, item2, item3 }; For objects with properties, you can combine object and collection initialization − ...

Read More

Action Delegate in C#

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

The Action delegate in C# is a built-in generic delegate type that represents a method with no return value (void). It can accept zero or more input parameters and is particularly useful for passing methods as parameters or storing method references. Syntax Following is the basic syntax for declaring an Action delegate − Action actionDelegate = MethodName; For Action delegates with parameters − Action actionDelegate = MethodName; Action actionDelegate = MethodName; Action actionDelegate = MethodName; Where T, T1, T2, etc. are the parameter types. Using Action Delegate with Single ...

Read More

Multiple Where clause in C# Linq

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

In C# LINQ, you can apply multiple where clauses to filter collections based on different conditions. Each additional where clause further narrows down the results, creating a logical AND relationship between the conditions. Syntax There are two main approaches to using multiple where clauses − Query Syntax with Multiple Where Clauses: var result = from item in collection where condition1 where condition2 ...

Read More

C# Enum IsDefined Method

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

The Enum.IsDefined method in C# determines whether a specified value exists within a given enumeration. It returns true if the value is found, either as an integral value or its corresponding string name, and false otherwise. Syntax Following is the syntax for the Enum.IsDefined method − public static bool IsDefined(Type enumType, object value) Parameters enumType − The type of the enumeration to check against. value − The value to look for in the enumeration (can be an integer or string). Return Value Returns true if the specified value exists ...

Read More

C# int.Parse Method

Sai Subramanyam
Sai Subramanyam
Updated on 17-Mar-2026 24K+ Views

The int.Parse method in C# converts a string representation of a number to an integer. If the string cannot be converted to a valid integer, the method throws a FormatException. Syntax Following is the basic syntax for int.Parse − int result = int.Parse(stringValue); The method also has overloaded versions that accept additional parameters − int result = int.Parse(stringValue, NumberStyles.Integer); int result = int.Parse(stringValue, CultureInfo.InvariantCulture); Parameters s − A string containing a number to convert. style (optional) − A bitwise combination of enumeration values that indicates ...

Read More

C# OfType() Method

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

The OfType() method in C# is a LINQ extension method that filters a collection based on the type of its elements. It returns only the elements that match the specified type, making it useful for working with heterogeneous collections containing different data types. Syntax Following is the syntax for the OfType() method − public static IEnumerable OfType(this IEnumerable source) The method can be used with both method syntax and query syntax − // Method syntax var result = collection.OfType(); // Query syntax var result = from item in collection.OfType() select item; ...

Read More

C# Linq Where Method

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

The Where method in LINQ is used to filter elements from a collection based on a specified condition (predicate). It returns a new IEnumerable containing only the elements that satisfy the given criteria. Syntax The Where method has two overloads − // Filter based on element value only public static IEnumerable Where(this IEnumerable source, Func predicate) // Filter based on element value and index public static IEnumerable Where(this IEnumerable source, Func predicate) Parameters source − The input sequence to filter predicate − A function that tests each element for a condition ...

Read More

C# Program to make a copy of an existing file

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

The File.Copy method in C# is used to copy an existing file from one location to another. This method is part of the System.IO namespace and provides a simple way to duplicate files programmatically. Syntax Following is the syntax for the File.Copy method − File.Copy(string sourceFileName, string destFileName); File.Copy(string sourceFileName, string destFileName, bool overwrite); Parameters sourceFileName − The path of the file to copy. destFileName − The path of the destination file. overwrite − Optional boolean parameter. If true, overwrites the destination file if it already exists. ...

Read More
Showing 8211–8220 of 21,090 articles
« Prev 1 820 821 822 823 824 2109 Next »
Advertisements