karthikeya Boyini

karthikeya Boyini

1,421 Articles Published

Articles by karthikeya Boyini

Page 58 of 143

Bootstrap Horizontal Form

karthikeya Boyini
karthikeya Boyini
Updated on 11-Mar-2026 2K+ Views

To create a horizontal form in Bootstrap, follow the below steps − Add a class of .form-horizontal to the parent element. Wrap labels and controls in a with class .form-group. Add a class of .control-label to the labels.You can try to run the following code to create a horizontal form in Bootstrap −Example           Bootstrap Example                                                             First Name                                                                         Last Name                                                                                                           Remember me                                                                            Sign in                                

Read More

C# Program to remove duplicate characters from String

karthikeya Boyini
karthikeya Boyini
Updated on 11-Mar-2026 11K+ Views

Use Hashset to remove duplicate characters.Here is the string −string myStr = "kkllmmnnoo";Now, use HashSet to map the string to char. This will remove the duplicate characters from a string.var unique = new HashSet(myStr);Let us see the complete example −Exampleusing System; using System.Linq; using System.Collections.Generic; namespace Demo {    class Program {       static void Main(string[] args) {          string myStr = "kkllmmnnoo";          Console.WriteLine("Initial String: "+myStr);          var unique = new HashSet(myStr);          Console.Write("New String after removing duplicates: ");          foreach (char c in unique)          Console.Write(c);       }    } }OutputInitial String: kkllmmnnoo New String after removing duplicates: klmno

Read More

How to validate a string for a numeric representation using TryParse in C#

karthikeya Boyini
karthikeya Boyini
Updated on 11-Mar-2026 428 Views

The following is our string −string myStr = "5";To check whether the above is a string with numeric representation, use TryParse and out.int.TryParse(myStr, out a);Here is the complete code.Exampleusing System.IO; using System; class Program {    static void Main() {       bool res;       int a;       string myStr = "5";       // checking for valid string representation of a number       res = int.TryParse(myStr, out a);       Console.WriteLine(res);    } }OutputTrue

Read More

How to get int value from enum in C#?

karthikeya Boyini
karthikeya Boyini
Updated on 11-Mar-2026 278 Views

Firstly, set the enum −public enum Vehicle { Car, Bus, Truck }Now use typecasting to cast an enum to int −int a = (int)Vehicle.Car;The following is the complete code to cast an enum to int −Exampleusing System; public class Demo {    public enum Vehicle { Car, Bus, Truck }    public static void Main() {       int a = (int)Vehicle.Car;       int b = (int)Vehicle.Bus;       int c = (int)Vehicle.Truck;       Console.WriteLine("Car = {0}", a);       Console.WriteLine("Bus = {0}", b);       Console.WriteLine("Truck = {0}", c);    } }OutputCar = 0 Bus = 1 Truck = 2

Read More

Date Parsing using SimpleDateFormat

karthikeya Boyini
karthikeya Boyini
Updated on 11-Mar-2026 453 Views

The SimpleDateFormat class has parse() method, which tries to parse a string according to the format stored in the given SimpleDateFormat object.Exampleimport java.util.*; import java.text.*;   public class DateDemo {    public static void main(String args[]) {       SimpleDateFormat ft = new SimpleDateFormat ("yyyy-MM-dd");               String input = args.length == 0 ? "1818-11-11" : args[0];         System.out.print(input + " Parses as ");               Date t;       try {          t = ft.parse(input);                    System.out.println(t);               } catch (ParseException e) {                    System.out.println("Unparseable using " + ft);               }    } }A sample run of the above program would produce the following result −Output1818-11-11 Parses as Wed Nov 11 00:00:00 EST 1818

Read More

Print a 2 D Array or Matrix in C#

karthikeya Boyini
karthikeya Boyini
Updated on 11-Mar-2026 3K+ Views

First, set a two-dimensional array.int[, ] arr = new int[10, 10];Now, get the elements from the user −for (i = 0; i < m; i++) {    for (j = 0; j < n; j++) {       arr[i, j] = Convert.ToInt16(Console.ReadLine());    } }Let us see the complete example to display the matrix.Exampleusing System; using System.Linq; class Demo {    static void Main() {       int m, n, i, j;       // rows and columns of the matrix+       m = 2;       n = 2; ...

Read More

How to remove items from a list in C#?

karthikeya Boyini
karthikeya Boyini
Updated on 11-Mar-2026 509 Views

Firstly, set a list and add elements.List myList = new List(); myList.Add("Jennings"); myList.Add("James"); myList.Add("Chris");Let’s say you need to delete the element “James” now. For that, use the Remove() method.myList.Remove("James");Here is the complete code.Exampleusing System.Collections.Generic; using System; class Program {    static void Main() {       List myList = new List();       myList.Add("Jennings");       myList.Add("James");       myList.Add("Chris");       Console.WriteLine("Initial List...");       foreach(string str in myList) {          Console.WriteLine(str);       }       myList.Remove("James");       Console.WriteLine("New List...");       ...

Read More

C# program to print all sublists of a list

karthikeya Boyini
karthikeya Boyini
Updated on 11-Mar-2026 738 Views

Firstly, create a list −List list = new List();The string here is “xyz” for which we will find the sublists. While looping we will declare another list, that would generate sublists on every true iteration −for (int i = 1; i < str.Length; i++) {    list.Add(str[i - 1].ToString());    List newlist = new List();    for (int j = 0; j < list.Count; j++) {       string list2 = list[j] + str[i];       newlist.Add(list2);    }    list.AddRange(newlist); }The following is the complete code −Exampleusing System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Demo { ...

Read More

How to print the contents of array horizontally using C#?

karthikeya Boyini
karthikeya Boyini
Updated on 11-Mar-2026 2K+ Views

Set an array.int[] array = new int[] { 50, 100, 150, 200, 250, 300, 350, 400 };Now, if you will print this array using a loop and new line, then the arrays will be visible vertically.To work it horizontally, use the Join() method and set spaces to separate array elements.string.Join(" ", array)Let us see the complete code.Exampleusing System; using System.Linq; using System.IO; class Program {    static void Main() {       int[] array = new int[] { 50, 100, 150, 200, 250, 300, 350, 400 };       Console.WriteLine(string.Join(" ", array));    } }Output50 100 150 200 250 300 350 400

Read More

Lambda Expressions in C#

karthikeya Boyini
karthikeya Boyini
Updated on 11-Mar-2026 796 Views

A lambda expression in C# describes a pattern.Lambda Expressions has the token => in an expression context. This is read as “goes to” operator and used when a lambda expression is declared.Here, we are finding the first occurrence of the element greater than 50 from a list.list.FindIndex(x => x > 50);Above the token => is used. The same is shown below −Exampleusing System; using System.Collections.Generic; class Demo {    static void Main() {       List list = new List { 44, 6, 34, 23, 78 };       int res = list.FindIndex(x => x > 50);       Console.WriteLine("Index: "+res);    } }OutputIndex: 4

Read More
Showing 571–580 of 1,421 articles
« Prev 1 56 57 58 59 60 143 Next »
Advertisements