Server Side Programming Articles

Page 792 of 2109

How to print a blank line in C#?

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

To print a blank line in C#, you can use several methods. The most common approach is using Console.WriteLine() without any parameters, which outputs an empty line to the console. Syntax Following are the different ways to print a blank line − Console.WriteLine(); // Empty line Console.WriteLine(""); // Empty string Console.WriteLine(" "); // Single space Console.Write(""); // Newline character ...

Read More

How to print a BinaryTriangle using C#?

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

A binary triangle is a pattern formed using alternating 0s and 1s arranged in a triangular shape. Each row contains an increasing number of digits, and the pattern alternates between 0 and 1 for each position across all rows. How It Works The binary triangle is created using nested loops where the outer loop controls the number of rows, and the inner loop prints the alternating 0s and 1s for each row. A toggle variable switches between 0 and 1 to create the alternating pattern − Binary Triangle Pattern 1 ...

Read More

How to print a diamond using nested loop using C#?

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

A diamond pattern is a common programming exercise that demonstrates the use of nested loops in C#. The diamond shape consists of two parts: an upper triangle that expands and a lower triangle that contracts. To create a diamond pattern, you need to consider three key elements − Number of rows (determines diamond size) Characters to display (commonly $ or *) Leading spaces for alignment Diamond Pattern Structure Upper Triangle Row 1: 4 spaces + 1 char Row 2: 3 spaces + ...

Read More

How to print a line on the console using C#?

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

To display a line on the console in C#, we use the Console.WriteLine() method. This method prints text to the console and automatically adds a new line at the end. Syntax Following is the syntax for printing a line to the console − Console.WriteLine(value); Where value can be a string, variable, or any expression that can be converted to a string. Using Console.WriteLine() with Strings The most common use is to print string literals or string variables − using System; public class Program { public static ...

Read More

How to print multiple blank lines in C#?

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

In C#, there are several ways to print multiple blank lines to the console. You can use loops, string repetition, or direct method calls depending on your needs. Using a While Loop The most straightforward approach is to use a while loop to print blank lines repeatedly − using System; namespace Program { public class Demo { public static void Main(string[] args) { int a = 0; while ...

Read More

C# program to get max occurred character in a String

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

To find the maximum occurred character in a string in C#, we need to count the frequency of each character and then identify which character appears most frequently. This can be achieved using different approaches including character arrays and dictionaries. Syntax Using a character frequency array − int[] frequency = new int[256]; // ASCII characters for (int i = 0; i < str.Length; i++) frequency[str[i]]++; Using a dictionary for character counting − Dictionary charCount = new Dictionary(); foreach (char c in str) { charCount[c] ...

Read More

Understanding Logistic Regression in C#

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

Logistic regression is a statistical method used for binary classification problems. Unlike linear regression which predicts continuous values, logistic regression predicts the probability that an instance belongs to a particular category. It is widely used in medical science to predict disease outcomes and in business to forecast customer behavior. The key advantage of logistic regression is that it produces probabilities between 0 and 1, making it ideal for classification tasks. It also provides interpretable results through odds ratios and supports statistical hypothesis testing. Mathematical Foundation Logistic regression uses a linear model combined with the logistic function (sigmoid ...

Read More

How to check if an item exists in a C# list collection?

Arjun Thakur
Arjun Thakur
Updated on 17-Mar-2026 14K+ Views

In C#, you can check if an item exists in a List collection using several methods. The most common approach is the Contains() method, which returns true if the item is found and false otherwise. Syntax Following is the syntax for the Contains() method − bool Contains(T item) Parameters item − The object to locate in the list. The value can be null for reference types. Return Value Returns true if the item is found in the list; otherwise, false. Using Contains() Method Example using ...

Read More

How to find a matching substring using regular expression in C#?

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

Regular expressions in C# provide a powerful way to search for specific patterns within strings. The Regex.Matches() method from the System.Text.RegularExpressions namespace allows you to find all occurrences of a pattern in a string. To find a matching substring, you create a regex pattern and use it to search through your target string. The pattern can be a simple literal match or include special regex metacharacters for more complex searches. Syntax Following is the basic syntax for finding matches using regular expressions − MatchCollection matches = Regex.Matches(inputString, pattern); For word boundary matching, use ...

Read More

Formatted output in C#

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

In C#, formatted output allows you to control how data is displayed when converting values to strings. This is essential for presenting numbers, dates, and other data types in a user-friendly format using format specifiers and the String.Format() method. Syntax Following is the syntax for basic string formatting − String.Format("{index:format}", value) Where index is the parameter position (starting from 0) and format is the format specifier. Using Format Specifiers for Numbers Decimal Places and Thousands Separator using System; class Demo { public static void Main(String[] ...

Read More
Showing 7911–7920 of 21,090 articles
« Prev 1 790 791 792 793 794 2109 Next »
Advertisements