Server Side Programming Articles

Page 760 of 2109

C# program to convert decimal to Octal number

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

A decimal number can be converted to an octal number using the division method. Octal is a base-8 number system that uses digits 0-7. To convert from decimal to octal, we repeatedly divide the decimal number by 8 and collect the remainders. How It Works The conversion process involves dividing the decimal number by 8 repeatedly and storing the remainders. The octal equivalent is formed by reading the remainders in reverse order − Decimal 40 to Octal Conversion 40 ÷ 8 = 5 ...

Read More

C# Program to Count the Number of 1's in the Entered Numbers

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

This C# program demonstrates how to count the occurrences of a specific number (1) in an array of integers. We'll use an array to store the numbers and iterate through it to count how many times the value 1 appears. Syntax Following is the syntax for declaring an array and using a foreach loop to iterate through it − int[] arrayName = new int[] {value1, value2, value3}; foreach(int variable in arrayName) { // process each element } Using Array and foreach Loop The most straightforward approach is to use ...

Read More

C# program to count the occurrences of each character

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

Counting character occurrences in a string is a common programming task in C#. This can be accomplished using various approaches, from basic loops to modern LINQ methods and dictionary-based solutions. Using Basic Loop with String Manipulation The first approach uses a while loop and string replacement to count occurrences − using System; public class Demo { public static void Main() { string str = "Website"; Console.WriteLine("String: " + str); ...

Read More

C# program to count total set bits in a number

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

A set bit refers to a bit that has a value of 1 in the binary representation of a number. Counting set bits is a common programming problem that involves examining each bit position to determine how many are set to 1. For example, the number 11 in decimal has the binary representation 1011, which contains 3 set bits (three 1s). Approach The most straightforward approach uses bitwise operations to examine each bit − Use the bitwise AND operator (&) with 1 to check if the least significant bit is set Right-shift ...

Read More

C# Program to display name of Current Thread

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

To display the name of the current thread in C#, use the Name property of the Thread.CurrentThread object. This property allows you to both set and retrieve the name of the currently executing thread. Syntax Following is the syntax to get the current thread − Thread thread = Thread.CurrentThread; Following is the syntax to set and get the thread name − thread.Name = "ThreadName"; string currentName = thread.Name; Using Thread.CurrentThread Property The Thread.CurrentThread property returns a reference to the currently executing thread. You can then use the Name property ...

Read More

C# Program to display priority of Thread

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

In C#, thread priority determines how the operating system schedules threads for execution. The Priority property of the Thread class allows you to both view and set the priority of a thread. Thread priority is represented by the ThreadPriority enumeration. Syntax To get the current thread and display its priority − Thread thread = Thread.CurrentThread; ThreadPriority priority = thread.Priority; To set a thread's priority − thread.Priority = ThreadPriority.High; ThreadPriority Enumeration Values Priority Level Description Lowest The thread has the lowest priority ...

Read More

C# program to display factors of entered number

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

A factor of a number is any integer that divides the number evenly without leaving a remainder. For example, the factors of 12 are 1, 2, 3, 4, 6, and 12 because each of these numbers divides 12 exactly. To find factors of a number in C#, we use the modulus operator (%) to check if the remainder is zero when dividing the number by potential factors. Algorithm The algorithm to find factors involves the following steps − Start with 1 and iterate through all numbers up to the given number For each number, check ...

Read More

C# program to count upper and lower case characters in a given string

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

To count uppercase and lowercase characters in a string, we can iterate through each character and check if it falls within specific ASCII ranges. For uppercase letters, we check if the character is between 'A' and 'Z', while for lowercase letters, we check if it's between 'a' and 'z'. Syntax Following is the syntax for checking uppercase characters − if (myStr[i] >= 'A' && myStr[i] = 'a' && myStr[i] = 'a' && myStr[i] = 'A' && myStr[i]

Read More

C# program to find node in Linked List

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

The LinkedList class in C# provides methods to search for nodes within the list. The Find() method returns the first LinkedListNode that contains the specified value, or null if the value is not found. Syntax Following is the syntax for finding a node in a LinkedList − LinkedListNode node = linkedList.Find(value); Following is the syntax for finding the last occurrence of a node − LinkedListNode node = linkedList.FindLast(value); Return Value The Find() method returns a LinkedListNode object containing the value, or null if the value is not found. The ...

Read More

C# program to Display Hostname and IP address

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

To find the hostname of the current machine, use the Dns.GetHostName() method in C#. This method returns the host name of the local computer as a string. To get the IP addresses, use the IPHostEntry.AddressList property which provides an array of all IP addresses associated with the hostname. Syntax Following is the syntax for getting the hostname − string hostName = Dns.GetHostName(); Following is the syntax for getting IP addresses − IPHostEntry hostEntry = Dns.GetHostEntry(hostName); IPAddress[] addresses = hostEntry.AddressList; Example The following code demonstrates how to display hostname and ...

Read More
Showing 7591–7600 of 21,090 articles
« Prev 1 758 759 760 761 762 2109 Next »
Advertisements