Karthikeya Boyini has Published 2383 Articles

Compare two strings lexicographically in C#

karthikeya Boyini

karthikeya Boyini

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

2K+ Views

To compare strings in C#, use the compare() method. It compares two strings and returns the following integer values −If str1 is less than str2, it returns -1. If str1 is equal to str2, it returns 0. If str1 is greater than str2, it returns 1.Set the two ... Read More

Create Toast Message in Java Swing

karthikeya Boyini

karthikeya Boyini

Updated on 19-Jun-2020 12:08:08

952 Views

A toast message is an alert which disappears with time automatically. With JDK 7, we can create a toast message similar to an alert on android very easily. Following are the steps needed to make a toast message.Make a rounded rectangle shaped frame. Add a component listener to frame and ... Read More

Create a simple calculator using Java Swing

karthikeya Boyini

karthikeya Boyini

Updated on 19-Jun-2020 12:01:39

19K+ Views

Swing API is a set of extensible GUI Components to ease the developer's life to create JAVA based Front End/GUI Applications. It is built on top of AWT API and acts as a replacement of AWT API since it has almost every control corresponding to AWT controls.Following example showcases a ... Read More

How can we check the indexes created by a UNIQUE constraint on a MySQL table?

karthikeya Boyini

karthikeya Boyini

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

414 Views

SHOW INDEX statement is used to check the indexes created by a UNIQUE constraint on a MySQL table.SyntaxSHOW INDEX from table_name;ExampleSuppose we have the table ‘empl’ which have a UNIQUE constraint on column ‘empno’.mysql> describe empl; +--------+-------------+------+-----+---------+-------+ | Field  | Type        | Null | Key | Default ... Read More

C# Program to Kill a Thread

karthikeya Boyini

karthikeya Boyini

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

773 Views

Create a thread first and start it −// new thread Thread thread = new Thread(c.display); thread.Start();Now display the thread and set a stop function to stop the working of the thread −public void display() {    while (!flag) {       Console.WriteLine("It's Working");       Thread.Sleep(2000);    } ... Read More

C# Program to Pause a Thread

karthikeya Boyini

karthikeya Boyini

Updated on 19-Jun-2020 11:46:34

7K+ Views

To pause a thread in C#, use the sleep() method.You need to set the milliseconds for which you want the thread to pause, for example, for 5 seconds, use −Thread.Sleep(5000);ExampleLet us see how to loop through and set the sleep method to pause the thread.Live Demousing System; using System.Threading; namespace ... Read More

C# Program to perform Celsius to Fahrenheit Conversion

karthikeya Boyini

karthikeya Boyini

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

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

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

487 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

Advertisements