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
Articles by Ankith Reddy
Page 13 of 73
Write a C# program to find GCD and LCM?
GCD (Greatest Common Divisor)GCD is the largest positive integer that divides each of the integers.LCM (Least Common Multiple)LCM of two numbers is the smallest integer divisible by both the numbers.The following is an example to calculate the GCD and LCM. Here, we are calculating the LCM and GCD of 10 and 16 −Exampleusing System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Demo { class Program { static void Main(string[] args) { int val1, val2, n1, n2, x; int resLCM, resGCD; val1 = ...
Read MoreRemove Leading Zeros from a String in C#
Let’s say the following is our string with leading zeros.String str ="000234";Use the TrimStart() method and set the 0 to remove it.TrimStart(new Char[] { '0' } )The following is the complete code to remove leading zeros.Exampleusing System; class Program { static void Main() { String str ="000234".TrimStart(new Char[] { '0' } ); Console.WriteLine(str); } }Output234
Read MoreBootstrap Collapsible button
The collapsible button is used in Bootstrap to create a collapsible that can be shown or hidden on click.You can try to run the following code to create a collapsible button:Example Bootstrap Example Contact Us Click for more info... More You can also contact us on 9199****** for more information on our products.
Read MoreC# Program to write a number in hexadecimal format
Let’s say the following is the number −int a = 12250;You can work around the following ways to get a number in hexadecimal format −{0:x} {0:x8} {0:X} {0:X8}Here is the code −Exampleusing System; class Demo { static void Main() { int a = 12250; Console.WriteLine("{0:x}", a); Console.WriteLine("{0:x8}", a); Console.WriteLine("{0:X}", a); Console.WriteLine("{0:X8}", a); } }Output2fda 00002fda 2FDA 00002FDA
Read MoreWhat are the differences between constructors and destructors in C#?
ConstructorsA class constructor is a special member function of a class that is executed whenever we create new objects of that class.A constructor has exactly the same name as that of class and it does not have any return type.Constructor has the same name as the class name −class Demo { public Demo() {} }The following is an example −Exampleusing System; namespace LineApplication { class Line { private double length; // Length of a line public Line() { Console.WriteLine("Object is being created"); ...
Read MoreBootstrap well class
A well is a container in that causes the content to appear sunken or an inset effect on the page. To create a well, simply wrap the content that you would like to appear in the well with a containing the class of .well.You can try to run the following code to implement well class in Bootstrap −Example Bootstrap Example This is demo text!
Read MoreHow to initialize a string to an empty string in C#?
To initialize a string to an empty list −string myStr = null;Now, use the built-in method IsNullOrEmpty() to check whether the list is empty or not −if (string.IsNullOrEmpty(myStr)) { Console.WriteLine("String is empty or null!"); }Let us see the complete code −Exampleusing System; namespace Demo { class Program { static void Main(string[] args) { string myStr = null; if (string.IsNullOrEmpty(myStr)) { Console.WriteLine("String is empty or null!"); } Console.ReadKey(); } ...
Read MoreC# Program to generate random lowercase letter
Firstly, set Random class −Random random = new Random();Set a range under the Next() method. This displays a letter between 0 and 26.int a = random.Next(0, 26);Here is the complete code −Exampleusing System; using System.IO; using System.Linq; class Demo { static void Main() { Random random = new Random(); // random lowercase letter int a = random.Next(0, 26); char ch = (char)('a' + a); Console.WriteLine(ch); } }Outputt
Read MoreCreate a green color alert box that indicates a positive action in Bootstrap
To create a green color alert box indicating a positive action, use the alert-success class.To implement an alert-success class, you need to try to run the following code −Example Bootstrap Example Indicates a positive action!
Read MoreFunc generic type in C#
The Func generic type store anonymous methods and is a parameterized type.In the below example, we have 4 func type instance −The first type receives int and returns stringFunc one = (p) => string.Format("{0}", p);The second type receives bool & long and returns stringFunc two = (q, p) =>string.Format("{0} and {1}", q, p);The third type receives bool & int and returns stringFunc three = (q, p) => string.Format("{0} and {1}", q, p);The fourth type receives decimal and returns stringFunc four = (p) =>string.Format("{0}", p);Let us see how to display them −Exampleusing System; using System.IO; namespace Demo { class ...
Read More