Csharp Articles

Page 151 of 196

Convert.ToChar Method in C#

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

The Convert.ToChar() method in C# converts a specified value to its equivalent Unicode character representation. This method accepts various data types including integers, bytes, strings, and other numeric types, and returns a char value. Syntax Following are the common overloads of the Convert.ToChar() method − public static char ToChar(byte value) public static char ToChar(int value) public static char ToChar(string value) public static char ToChar(object value) Parameters value − The value to be converted to a Unicode character. This can be a numeric type, string, or object. Return Value ...

Read More

Convert.ToDateTime Method in C#

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

The Convert.ToDateTime method in C# converts a string representation of a date and time to a DateTime object. This method is commonly used when you need to parse date strings from user input, files, or external data sources into a usable DateTime format. The method supports various date formats and provides automatic parsing based on the current culture settings of your system. Syntax Following are the most commonly used overloads of Convert.ToDateTime − public static DateTime ToDateTime(string value) public static DateTime ToDateTime(string value, IFormatProvider provider) public static DateTime ToDateTime(object value) Parameters ...

Read More

Different Star Pattern Programs in C#

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

Star pattern programs are common programming exercises that help developers practice loops and understand nested iteration logic. C# provides simple syntax to create various star patterns using for loops and Console.Write() methods. Common Star Pattern Types Right Triangle * ** Pyramid * *** Inverted *** ** Diamond * *** Right Triangle Pattern This pattern creates a right-angled triangle where each row contains one more star than the previous row − using System; class Program { static void Main() { for (int i = 1; i

Read More

C# Program to merge sequences

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

In C#, you can merge sequences using the Zip method from LINQ. The Zip method combines elements from two sequences by pairing them together using a specified function. Syntax The Zip method syntax is − sequence1.Zip(sequence2, (first, second) => result) Parameters sequence1 − The first sequence to merge sequence2 − The second sequence to merge resultSelector − A function that defines how to combine elements from both sequences How It Works The Zip method pairs elements from two sequences by their index position. If sequences have different lengths, the ...

Read More

C# Program to create a LinkedList

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

A LinkedList in C# is a generic collection that stores elements in nodes, where each node contains the data and references to the next and previous nodes. Unlike arrays, LinkedList elements are not stored in contiguous memory locations and allow efficient insertion and removal operations. Syntax Following is the syntax for creating a LinkedList − LinkedList listName = new LinkedList(); You can also create a LinkedList from an existing collection − LinkedList listName = new LinkedList(collection); Creating LinkedList from Array You can create a LinkedList by passing an array ...

Read More

C# Program to invert the order of elements in a sequence

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

In C#, you can invert the order of elements in a sequence using several built-in methods. The most common approaches include using Queryable.Reverse() with LINQ, Array.Reverse(), and Enumerable.Reverse(). Each method has its specific use cases and performance characteristics. Syntax Following is the syntax for using Queryable.Reverse() method − IQueryable result = sequence.AsQueryable().Reverse(); Following is the syntax for using Array.Reverse() method − Array.Reverse(array); Following is the syntax for using Enumerable.Reverse() method − IEnumerable result = sequence.Reverse(); Using Queryable.Reverse() Method The Queryable.Reverse() method returns an IQueryable that ...

Read More

C# Program to return a collection with repeated elements

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

To return a collection with repeated elements in C#, use the Enumerable.Repeat method from the System.Linq namespace. This method creates a sequence that contains one repeated value a specified number of times. Syntax Following is the syntax for Enumerable.Repeat method − public static IEnumerable Repeat(TResult element, int count) Parameters element − The value to be repeated in the result sequence. count − The number of times to repeat the value in the generated sequence. Return Value Returns an IEnumerable that contains a repeated value. ...

Read More

Convert.ToInt32 Method in C#

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

The Convert.ToInt32() method in C# converts a specified value to a 32-bit signed integer. This method provides type conversion from various data types including string, double, float, decimal, and bool to int. The method uses rounding to nearest even (banker's rounding) when converting floating-point numbers, and throws exceptions for invalid conversions like null strings or out-of-range values. Syntax Following are the common overloads of Convert.ToInt32() method − Convert.ToInt32(object value) Convert.ToInt32(string value) Convert.ToInt32(double value) Convert.ToInt32(bool value) Parameters value − The value to convert to a 32-bit signed integer. Return Value ...

Read More

Implicit conversion from Int16 to Decimal in C#

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

The short type in C# represents a 16-bit signed integer (Int16) that can store values from -32, 768 to 32, 767. C# allows implicit conversion from short to decimal because this conversion is always safe and will never result in data loss. An implicit conversion means the compiler automatically performs the type conversion without requiring an explicit cast operator. This is possible because decimal has a much larger range and precision than short. Syntax The syntax for implicit conversion from Int16 to Decimal is straightforward − short shortValue = value; decimal decimalValue = shortValue; ...

Read More

Implicit conversion from Char to Decimal in C#

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

In C#, implicit conversion from char to decimal happens automatically when you assign a character value to a decimal variable. The character is converted to its corresponding ASCII or Unicode numeric value, which is then stored as a decimal number. Syntax Following is the syntax for implicit conversion from char to decimal − char c = 'character'; decimal dec = c; // implicit conversion How It Works When you assign a char to a decimal, C# automatically converts the character to its numeric ASCII/Unicode value. For example, the character 'A' has an ...

Read More
Showing 1501–1510 of 1,951 articles
« Prev 1 149 150 151 152 153 196 Next »
Advertisements