Samual Sam has Published 2310 Articles

C# Program to perform all Basic Arithmetic Operations

Samual Sam

Samual Sam

Updated on 19-Jun-2020 11:44:15

9K+ Views

Basic Arithmetic Operators in C#, include the following −OperatorDescription+Adds two operands-Subtracts the second operand from the first*Multiplies both operands/Divides the numerator by de-numerator%Modulus Operator and remainder of after an integer division++Increment operator increases integer value by one--Decrement operator decreases integer value by oneTo add, use the Addition Operator −num1 + ... Read More

C# program to split and join a string

Samual Sam

Samual Sam

Updated on 19-Jun-2020 11:39:37

3K+ Views

To split and join a string in C#, use the split() and join() method. Let us say the following is our string −string str = "This is our Demo String";To split the string, we will use the split() method −var arr = str.Split(' ');Now to join, use the join() method ... Read More

C# Program to create a Simple Thread

Samual Sam

Samual Sam

Updated on 19-Jun-2020 11:38:02

560 Views

To create a thread, I have created a function −public void myThread() {    for (int i = 0; i < 3; i++) {       Console.WriteLine("My Thread");    } }The above function is called to create a thread and a new ThreadStart delegate is created −Demo d = ... Read More

C# program to reverse a string

Samual Sam

Samual Sam

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

12K+ Views

Our sample string is −myStr = "Tom";To reverse the string, firstly find the length of the string −// find string length int len; len = myStr.Length - 1;Now, use a while loop until the length is greater than 0 −while (len >= 0) {    rev = rev + myStr[len]; ... Read More

C# program to Reverse words in a string

Samual Sam

Samual Sam

Updated on 19-Jun-2020 11:29:21

3K+ Views

Let’s say the following is the string −Hello WorldAfter reversing the string, the words should be visible like −olleH dlroWExampleUse the reverse() method and try the following code to reverse words in a string.Live Demousing System; using System.Linq; class Demo {    static void Main() {       // ... Read More

C# Program to implement Sleep Method Of Thread

Samual Sam

Samual Sam

Updated on 19-Jun-2020 11:27:24

389 Views

The sleep method of the thread is used to pause the thread for a specific period.If you want to set sleep for some seconds, then use it like the following code snippet −int sleepfor = 2000; Thread.Sleep(sleepfor);ExampleYou can try to run the following code to implement the sleep method of ... Read More

C# Program to count vowels in a string

Samual Sam

Samual Sam

Updated on 19-Jun-2020 11:25:55

9K+ Views

You need to check for both the vowels and consonants, but do not forget to check for both the uppercase as well lowercase.For counting vowels, check for “aeiou” characters separately i.e.if (myStr[i] == 'a' || myStr[i] == 'e' || myStr[i] == 'i' || myStr[i] == 'o' || myStr[i] == 'u' ... Read More

What is MySQL NOT NULL constraint and how can we declare a field NOT NULL while creating a table?

Samual Sam

Samual Sam

Updated on 19-Jun-2020 11:24:42

421 Views

Actually, MySQL NOT NULL constraint restricts a column of the table from having a NULL value. Once we applied NOT NULL constraint to a column, then we cannot pass a null value to that column. It cannot be declared on the whole table i.e., in other words, we can say ... Read More

C# Program to display priority of Thread

Samual Sam

Samual Sam

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

388 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

Advertisements