Karthikeya Boyini has Published 2193 Articles

C# program to get max occurred character in a String

karthikeya Boyini

karthikeya Boyini

Updated on 22-Jun-2020 09:13:02

846 Views

To get the maximum occurred character in a string, loop until the length of the given string and find the occurrence.With that, set a new array to calculate −for (int i = 0; i < s.Length; i++)    a[s[i]]++; }The values we used above −String s = "livelife!"; int[] a ... Read More

How to print the first ten Fibonacci numbers using C#?

karthikeya Boyini

karthikeya Boyini

Updated on 22-Jun-2020 09:09:04

772 Views

For displaying the first ten numbers, firstly set the first two numbers.int val1 = 0, val2 = 1;Now, use a for loop from 2 to 10, to display first ten Fibonacci numbers −for(i=2;i

How to remove an empty string from a list of empty strings in C#?

karthikeya Boyini

karthikeya Boyini

Updated on 22-Jun-2020 09:06:28

1K+ Views

Firstly, set a list with empty string as elements.List myList = new List() {    " ",    " ",    " " };Now let us remove one empty element using index.myList.RemoveAt(0);Example Live Demousing System; using System.Collections.Generic; using System.Linq; class Program {    static void Main() {       ... Read More

How to find a substring from a string in C#?

karthikeya Boyini

karthikeya Boyini

Updated on 22-Jun-2020 09:03:24

296 Views

Set the stringstring s = "Tom Cruise";Now let’s say you need to find the substring “Tom”, then use the Contains() method.if (s.Contains("Tom") == true) {    Console.WriteLine("Substring found!"); }The following is the code to learn how to find a substring from a string −Example Live Demousing System; public class Demo ... Read More

Lambda Expressions in C#

karthikeya Boyini

karthikeya Boyini

Updated on 22-Jun-2020 08:58:21

706 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 > ... Read More

How to convert a list of characters into a string in C#?

karthikeya Boyini

karthikeya Boyini

Updated on 22-Jun-2020 08:55:42

326 Views

Firstly, set the characters.char[] arr = new char[5]; arr[0] = 'Y'; arr[1] = 'E'; arr[2] = 'S';Now, convert them into string.string res = new string(arr);The following is the complete code to convert a list of characters into a string −Example Live Demousing System; class Program {    static void Main() ... Read More

How to print all the Armstrong Numbers from 1 to 1000 using C#?

karthikeya Boyini

karthikeya Boyini

Updated on 22-Jun-2020 08:35:01

451 Views

To display Armstrong numbers from 1 to 100, firstly use a while loop.Examplewhile (val

What is a managed code in C#?

karthikeya Boyini

karthikeya Boyini

Updated on 22-Jun-2020 08:23:32

417 Views

Managed code is a code whose execution is managed by Common Language Runtime. It gets the managed code and compiles it into machine code. After that, the code is executed.The runtime here i.e. CLR provides automatic memory management, type safety, etc.Managed code is written in high-level languages run on top ... Read More

Checked vs Unchecked Exceptions in C#

karthikeya Boyini

karthikeya Boyini

Updated on 22-Jun-2020 08:21:35

3K+ Views

You can execute statements in C# in checked or unchecked context.In checked, the exception is raised by arithmetic overflow, whereas in unchecked context, arithmetic overflow is ignored.Checked ExceptionsUse the checked keyword to explicitly enable overflow checking for integral-type arithmetic operations and conversions. For this, just set the checked keyword.Overflow checking ... Read More

How can I convert the epoch stored in MySQL table into readable dates?

karthikeya Boyini

karthikeya Boyini

Updated on 22-Jun-2020 08:05:29

143 Views

To illustrate it we are using the following example of a table named ‘vistors’ which have the epoch as follows −mysql> Create table visitors(userid int not null, name varchar(20), epoch int NOT NULL); Query OK, 0 rows affected (0.42 sec) mysql> Insert into visitors Values(1, 'Gaurav', 1358658942); Query OK, ... Read More

Advertisements