Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles by karthikeya Boyini
Page 56 of 143
Decimal constants in C#
Decimal type has constants to get the minimum and maximum values.Set a decimal value −decimal d = 5.8M;To get the minimum and maximum values of the decimal type, use the following properties −decimal.MaxValue decimal.MinValueHere is the complete code −Exampleusing System; using System.Linq; class Demo { static void Main() { decimal d = 5.8M; Console.WriteLine(d); Console.WriteLine("Maximum Value: "+decimal.MaxValue); Console.WriteLine("Maximum Value: "+decimal.MinValue); } }Output5.8 Maximum Value: 79228162514264337593543950335 Maximum Value: -79228162514264337593543950335
Read MoreC# Program to check if a number is Positive, Negative, Odd, Even, Zero
Check for the following conditions −For odd and even, check for the remainder when the number is divided by 2 −// checking for odd/ even if(n % 2 == 0) { Console.WriteLine("Even"); } else { Console.WriteLine("Odd"); }For positive, negative and checking whether a number is 0 or not −if (n < 0) { Console.WriteLine("Negative Number!"); } else if(n == 0) { Console.WriteLine("Zero"); } else { Console.WriteLine("Positive Number!"); }The following is the complete code:Exampleusing System; using System.Collections.Generic; public class Demo { public static void Main(string[] args) { int n = 19; ...
Read MoreAdd HTML Content to Bootstrap List Group
Bootstrap list groups are added using the list-group-item class.Add HTML content to the linked list groups using the following codeExample Bootstrap Example Tutorials Programming Tutorials on Java, C, C++, etc. Web Development Tutorials on PHP, HTML5, etc. Database Tutorials on DBMS, MySQL, DB2, etc. Quiz CAT Quiz for CAT students. NEET Quiz for NEET students.
Read MoreC# Program to display temporary file names
The GetTempPath() method in C# displays temporary file names −Path.GetTempPath();Get the names in a variable and display −string tempFile = Path.GetTempPath();The following is the code −Exampleusing System; using System.IO; class Demo { static void Main() { string tempFile = Path.GetTempPath(); Console.WriteLine(tempFile); } }Output/tmp/
Read MoreC# program to count upper and lower case characters in a given string
To count uppercase characters in a string, check the following condition −myStr[i]>='A' && myStr[i]='a' && myStr[i]
Read MoreC# program to replace all spaces in a string with '%20'
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’.using System; class Demo { static void Main() { String str, str2; str ="Hello World !"; Console.WriteLine("String: "+str); str2 = str.Replace(" ", "%20"); Console.WriteLine("String (After replacing): "+str2); } }OutputString: Hello World ! String (After replacing): Hello%20World%20!
Read MoreSet the width of an element to 25% in Bootstrap
To set the width of an element to 25%, use the .w-25 class in Bootstrap.You can try to run the following code to set element’s widthExample Bootstrap Example Set element width Normal width Width is 50% Width is 25%
Read MoreC# Program to Illustrate Lower Triangular Matrix
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.using System; using System.Linq; class Demo { static void Main() { int m, n, i, j; Console.Write("Enter number of rows and columns of the matrix "); m = Convert.ToInt16(Console.ReadLine()); n = Convert.ToInt16(Console.ReadLine()); int[, ] A = new int[10, 10]; ...
Read MoreC# Program to Kill a Thread
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); } } public void Stop() { flag = true; } }ExampleThe following is the complete code to learn how to kill a thread in C#.using System; using System.Threading.Tasks; using System.Threading; class Demo { static void Main(string[] args){ MyClass c = new MyClass(); ...
Read MoreSet the width of an element to 100% in Bootstrap
To set the width of an element to 100%, use the .w-100 class in Bootstrap.You can try to run the following code to set element’s widthExample Bootstrap Example Set element width Normal width Width is 25%
Read More