Samual Sam has Published 2492 Articles

C# Program to display priority of Thread

Samual Sam

Samual Sam

Updated on 19-Jun-2020 11:16:52

263 Views

To show the priority of the thread in C#, use the Priority property.Firstly, use the currentThread property to display information about a thread −Thread thread = Thread.CurrentThread;Now use the thread.Priority property to display the priority of the thread −thread.PriorityExampleLet us see the complete code to show the thread’s priority in ... Read More

C# Program to find all substrings in a string

Samual Sam

Samual Sam

Updated on 19-Jun-2020 10:57:17

2K+ Views

Use the substring() method in C# to find all substrings in a string.Let’s say our string is −XyzLoop through the length of the string and use the Substring function from the beginning to the end of the string −for (int start = 0; start

C# program to find node in Linked List

Samual Sam

Samual Sam

Updated on 19-Jun-2020 10:52:04

426 Views

Firstly, create a new linked list −LinkedList myList = new LinkedList();Now add some elements in the linked list −// Add 6 elements in the linked list myList.AddLast("P"); myList.AddLast("Q"); myList.AddLast("R"); myList.AddLast("S"); myList.AddLast("T"); myList.AddLast("U");Let’s now find a node and add a new node after that −LinkedListNode node = myList.Find("R"); myList.AddAfter(node, "ADDED");ExampleYou can ... Read More

C# program to convert decimal to Octal number

Samual Sam

Samual Sam

Updated on 19-Jun-2020 09:36:15

572 Views

Set the decimal number −int decVal = 40;Now take a variable and set the decVal in it. Find the remainder with 8 since octal has base-8 number system and evaluate it in a loop like the following code snippet.while (quot != 0) {    octalVal[i++] = quot % 8;   ... Read More

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

Samual Sam

Samual Sam

Updated on 19-Jun-2020 09:33:57

420 Views

I have added the numbers using an array −int[] num = new int[] {1, 25, 1, 55, 1};Now loop through and find for 1, if 1 is there, 6 then increment the variable that counts the occurrence −foreach(int j in num) {    if (j == 1) {     ... Read More

C# program to count total bits in a number

Samual Sam

Samual Sam

Updated on 19-Jun-2020 09:32:32

403 Views

Let us say the number we have is 12. We have declared and initialized a uint variable by assigning a decimal literal, uint val = 12;The binary representation of 12 is −1100The bits above is 4, therefore to find the total bits, use the Math.log() method −uint res = (uint)Math.Log(val ... Read More

C# Program to convert Digits to Words

Samual Sam

Samual Sam

Updated on 19-Jun-2020 09:29:32

3K+ Views

Firstly, declare the words from 0 to 9 −// words for every digits from 0 to 9 string[] digits_words = { "zero", "one", "two",    "three", "four", "five",    "six", "seven", "eight",    "nine" };The following are the digits to be converted to words −// number to be converted into ... Read More

C# Program to Convert Fahrenheit to Celsius

Samual Sam

Samual Sam

Updated on 19-Jun-2020 09:28:03

2K+ Views

Firstly, set the Fahrenheit temperature −double fahrenheit = 97; Console.WriteLine("Fahrenheit: " + fahrenheit);Now convert it into Celsius −celsius = (fahrenheit - 32) * 5 / 9;ExampleYou can try to run the following code to convert Fahrenheit to Celsius.Live Demousing System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Demo {   ... Read More

C# program to check if a string contains any special character

Samual Sam

Samual Sam

Updated on 19-Jun-2020 09:06:09

9K+ Views

To check if a string contains any special character, you need to use the following method −Char.IsLetterOrDigitUse it inside for loop and check or the string that has special characters.Let us say our string is −string str = "Amit$#%";Now convert the string into character array −str.ToCharArray();With that, use a for ... Read More

C# program to check password validity

Samual Sam

Samual Sam

Updated on 19-Jun-2020 09:05:00

748 Views

While creating a password, you may have seen the validation requirements on a website like a password should be strong and have −Min 8 char and max 14 charOne lower caseNo white spaceOne upper caseOne special charLet us see how to check the conditions one by one −Min 8 char ... Read More

Advertisements