Ankith Reddy

Ankith Reddy

730 Articles Published

Articles by Ankith Reddy

Page 15 of 73

How to print one dimensional array in reverse order?

Ankith Reddy
Ankith Reddy
Updated on 11-Mar-2026 597 Views

Firstly, declare and initialize one dimensional array.int[] arr = { 35, 12, 66, 90, 34, 2, 64 };Now, use the following to reverse −Array.Reverse(arr);The following is the complete code to reverse a one-dimensional array;Exampleusing System; class Demo {    static void Main() {       int[] arr = { 76, 12, 66, 90, 34, 2, 64 };       // Initial Array       Console.WriteLine("Original Array= ");       foreach (int i in arr) {          Console.WriteLine(i);       }       // Reverse Array       Array.Reverse(arr);       Console.WriteLine("Reversed Array= ");       foreach (int j in arr) {          Console.WriteLine(j);       }       Console.ReadLine();    } }OutputOriginal Array= 76 12 66 90 34 2 64 Reversed Array= 64 2 34 90 66 12 76

Read More

Find missing number in a sequence in C#

Ankith Reddy
Ankith Reddy
Updated on 11-Mar-2026 1K+ Views

Set a list.List myList = new List(){1, 2, 3, 5, 8, 9};Now, get the first and last elements −int a = myList.OrderBy(x => x).First(); int b = myList.OrderBy(x => x).Last();In a new list, get all the elements and use the Except to get the missing numbers −List myList2 = Enumerable.Range(a, b - a + 1).ToList(); List remaining = myList2.Except(myList).ToList();Let us see the complete code −Exampleusing System.Collections.Generic; using System; using System.Linq; public class Program {    public static void Main() {       List myList = new List(){1, 2, 3, 5, 8, 9};       Console.WriteLine("Numbers... ");   ...

Read More

How to find a number in a string in C#?

Ankith Reddy
Ankith Reddy
Updated on 11-Mar-2026 470 Views

To find a number in a string, use Regular Expressions.We have set the Regex pattern to get number from a string.Regex r = new Regex(@"\d+");Now, use Match class in C# to set the string.Match m = r.Match("Welcome! We are open 365 days in a year!");Use the Success property now to display the result if number is found in the string as shown in the following complete code −Exampleusing System; using System.Text.RegularExpressions; class Demo {    static void Main() {       Regex r = new Regex(@"\d+");       Match m = r.Match("Welcome! We are open 365 ...

Read More

Enumerable.Repeat method in C#

Ankith Reddy
Ankith Reddy
Updated on 11-Mar-2026 3K+ Views

Enumerable.Repeat method is part of System.Linq namespace.It returns a collection with repeated elements in C#.Firstly, set which element you want to repeat and how many times.As an example, let us see how to repeat number 10, five times −Enumerable.Repeat(10, 5);The following is the complete example −Exampleusing System; using System.Linq; class Demo {    static void Main() {       var val = Enumerable.Repeat(10, 5);       foreach (int res in val) {          Console.WriteLine(res);       }    } }Output10 10 10 10 10

Read More

Bootstrap .btn-link class

Ankith Reddy
Ankith Reddy
Updated on 11-Mar-2026 360 Views

Deemphasize a button by making it look like a link while maintaining button behavior using the btn-link class in Bootstrap −Example           Bootstrap Example                                       Link Button    

Read More

How to demonstrate Prefix Operator using C#?

Ankith Reddy
Ankith Reddy
Updated on 11-Mar-2026 301 Views

The increment operator is ++ operator. If used as prefix on a variable, the value of variable gets incremented by 1. After that the value is returned unlike Postfix operator. It is called Prefix increment operator. In the same way the decrement operator works but it decrements by 1.For example, ++a;The following is an example demonstrating Prefix increment operator −Exampleusing System; class Program {    static void Main() {       int a, b;       a = 10;       Console.WriteLine(++a);       b = a;       Console.WriteLine(a);       Console.WriteLine(b);    } }Output11 11 11

Read More

How to use #if..#elif…#else…#endif directives in C#?

Ankith Reddy
Ankith Reddy
Updated on 11-Mar-2026 1K+ Views

All preprocessor directives begin with #, and only white-space characters may appear before a preprocessor directive on a line. Preprocessor directives are not statements, so they do not end with a semicolon (;).#ifThe #if directive allows testing a symbol or symbols to see if they evaluate to true.#elseIt allows to create a compound conditional directive, along with #if.#elifIt allows creating a compound conditional directive.#endifThe #endif specifies the end of a conditional directive.The following is an example showing the usage of #if, #elif, #else and #endif directives −Example#define One #undef Two using System; namespace Demo {    class Program ...

Read More

C# Program to display the first element from an array

Ankith Reddy
Ankith Reddy
Updated on 11-Mar-2026 2K+ Views

The following is our array −double[] myArr = {20.5, 35.6, 45.7, 55.6, 79.7};To get the first element, use the First() method.myArr.AsQueryable().First();Let us see the complete code −Exampleusing System; using System.Linq; using System.Collections.Generic; class Demo {    static void Main() {       double[] myArr = {20.5, 35.6, 45.7, 55.6, 79.7};       double res = myArr.AsQueryable().First();       Console.WriteLine(res);    } }Output20.5

Read More

Disable a Bootstrap Button

Ankith Reddy
Ankith Reddy
Updated on 11-Mar-2026 2K+ Views

When you disable a button, it will fade in color by 50%, and lose the gradient. Use disabled to disable any button.To disable a button, you can try to run the following code −Example           Bootstrap Example                                 The following are some buttons:                Default Button                      Active Button                      Disabled Button          

Read More

Bootstrap class pull-left

Ankith Reddy
Ankith Reddy
Updated on 11-Mar-2026 623 Views

Float an element to the left with class pull-left.You can try to run the following code to implement the pull-left class −Example           Bootstrap Example                                          Float to left          

Read More
Showing 141–150 of 730 articles
« Prev 1 13 14 15 16 17 73 Next »
Advertisements