Karthikeya Boyini has Published 2193 Articles

C# Program to perform Celsius to Fahrenheit Conversion

karthikeya Boyini

karthikeya Boyini

Updated on 19-Jun-2020 11:41:12

8K+ Views

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

C# program to find the maximum of three numbers

karthikeya Boyini

karthikeya Boyini

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

14K+ Views

Firstly, let’s set the three numbers −int num1, num2, num3; // set the value of the three numbers num1 = 10; num2 = 20; num3 = 50;Now check the first number with the second number. If num1 > num2, then check num1 with num3. If num1 is greater than num3, ... Read More

C# Program to Create a Thread Pool

karthikeya Boyini

karthikeya Boyini

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

652 Views

For a thread pool, create more than two functions and queue methods for execution.Firstly, create a method like −public void one(object o) {    for (int i = 0; i

C# program to Display Hostname and IP address

karthikeya Boyini

karthikeya Boyini

Updated on 19-Jun-2020 11:35:28

1K+ Views

To find the hostname, use the Dns.GetHostName() method in C# −String hostName = string.Empty; hostName = Dns.GetHostName(); Console.WriteLine("Hostname: "+hostName);Now, use the IPHostEntry.AddressList Property to get IP Address −IPHostEntry myIP = Dns.GetHostEntry(hostName); IPAddress[] address = myIP.AddressList;ExampleTry the following code to display hostname and IP address −using System; using System.Net; class Program ... Read More

C# program to replace all spaces in a string with ‘%20’

karthikeya Boyini

karthikeya Boyini

Updated on 19-Jun-2020 11:33:45

3K+ Views

We have a sample string with spaces −str ="Hello World !";Use the Replace() method in C# to replace all spaces in a string with ‘%20’ −str2 = str.Replace(" ", "%20");ExampleYou can try to run the following code to replace all spaces in a string with ‘%20’.Live Demousing System; class Demo ... Read More

C# program to reverse an array

karthikeya Boyini

karthikeya Boyini

Updated on 19-Jun-2020 11:30:41

3K+ Views

Firstly, set the original array −int[] arr = { 15, 16, 17, 18 }; // Original Array Console.WriteLine("Original Array= "); foreach (int i in arr) {    Console.WriteLine(i); }Now, use the Array.reverse() method to reverse the array −Array.Reverse(arr);ExampleThe following is the complete code to reverse an array in C#Live Demousing ... Read More

C# program to find IP Address of the client

karthikeya Boyini

karthikeya Boyini

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

2K+ Views

Firstly find the hostname using the Dns.GetHostName() method in C# −String hostName = string.Empty; hostName = Dns.GetHostName(); Console.WriteLine("Hostname: "+hostName);Now, use the IPHostEntry.AddressList Property to get IP Address −IPHostEntry myIP = Dns.GetHostEntry(hostName); IPAddress[] address = myIP.AddressList;ExampleTry the following code to display IP address −using System; using System.Net; class Program {   ... Read More

C# Program to Illustrate Lower Triangular Matrix

karthikeya Boyini

karthikeya Boyini

Updated on 19-Jun-2020 11:26:45

269 Views

For the lower triangular matrix, set all the elements above the main diagonal to zero.Set the following condition −if (i >= j)    Console.Write(A[i, j] + "\t"); else    Console.Write("0\t");ExampleYou can try to run the following code to display a lower triangular matrix.Live Demousing System; using System.Linq; class Demo { ... Read More

What happens when we apply NOT NULL constraint, with ALTER TABLE statement, to a column contains NULL values?

karthikeya Boyini

karthikeya Boyini

Updated on 19-Jun-2020 11:26:11

259 Views

In this case, MySQL will return an error message regarding data truncated for the column. Following is an example of demonstrating it −ExampleSuppose we have a table ‘test2’ which contains a NULL value in column ‘ID’ at 2nd row. Now, if we will try to declare the column ID to ... Read More

C# Program to display name of Current Thread

karthikeya Boyini

karthikeya Boyini

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

247 Views

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

Advertisements