Samual Sam has Published 2492 Articles

C# program to Illustrate Upper Triangular Matrix

Samual Sam

Samual Sam

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

393 Views

For the upper triangular matrix, set all the elements below the main diagonal to zero.Set the following condition −if (i = j)                Console.Write(A[i, j] + "\t");             else                Console.Write("0\t");          }       }       Console.ReadLine();    } }OutputEnter number of rows and columns of the matrix   Enter elements:   Upper Triangular Matrix 

C# Program to pass Parameter to a Thread

Samual Sam

Samual Sam

Updated on 19-Jun-2020 11:47:31

4K+ Views

To work with threads, add the following namespace in your code −using System.Threading;Firstly, you need to create a new thread in C# −Thread thread = new Thread(threadDemo);Above, threadDemo is our thread function.Now pass a parameter to the thread −thread.Start(str);The parameter set above is −String str = "Hello World!";ExampleLet us see ... Read More

C# Program to perform all Basic Arithmetic Operations

Samual Sam

Samual Sam

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

7K+ 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

2K+ 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

433 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

11K+ 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

2K+ 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

247 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

7K+ 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

302 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

Advertisements