Convert Time from 12-Hour to 24-Hour Format in C#

George John
Updated on 22-Jun-2020 09:36:23

12K+ Views

Firstly, set the 12 hr format date.DateTime d = DateTime.Parse("05:00 PM");Now let us convert it into 24-hr format.d.ToString("HH:mm"));The following is the code to covert time from 12 hour to 24 hour format −Example Live Demousing System; namespace Demo {    public class Program {       public static void Main(string[] args) {          DateTime d = DateTime.Parse("05:00 PM");          Console.WriteLine(d.ToString("HH:mm"));       }    } }Output17:00

Find All Duplicate Elements in an Integer Array

karthikeya Boyini
Updated on 22-Jun-2020 09:35:59

9K+ Views

Firstly, set the array with duplicate elements.int[] arr = {    24,    10,    56,    32,    10,    43,    88,    32 };Now declare a Dictionary and loop through the array to get the repeated elements.var d = new Dictionary < int, int > (); foreach(var res in arr) {    if (d.ContainsKey(res))          d[res]++;    else    d[res] = 1; }Example Live Demousing System; using System.Collections.Generic; namespace Demo {    public class Program {       public static void Main(string[] args) {          int[] arr = {   ... Read More

Find Common Elements in Three Arrays Using Sets in C#

Chandu yadav
Updated on 22-Jun-2020 09:34:05

537 Views

Set three arraysint[] arr1 = {    99,    57,    63,    98 }; int[] arr2 = {    43,    99,    33,    57 }; int[] arr3 = {    99,    57,    42 };Now set the above elements using HashSet.// HashSet One var h1 = new HashSet < int > (arr1); // HashSet Two var h2 = new HashSet < int > (arr2); // HashSet Three var h3 = new HashSet < int > (arr3);Let us see the complete code to find common elements.Exampleusing System; using System.Collections.Generic; using System.Linq; public class Program ... Read More

CSS overflow-y Property

Prabhas
Updated on 22-Jun-2020 09:33:36

269 Views

The CSS overflow-y allows you to decide what to do with the top bottom edges of the content. You can try to run the following code to implement the overflow-y property −ExampleLive Demo                    div {             background-color: orange;             width: 250px;             height: 45px;             border: 2px solid blue;             overflow-x: hidden;             overflow-y: scroll;          }                     Heading       Overflow property used here. This is a demo text to show the working of CSS overflow-x and overflow-y.     Output

Find Largest, Smallest, Second Largest, and Second Smallest in a List

Samual Sam
Updated on 22-Jun-2020 09:31:34

2K+ Views

Set the listvar val = new int[] {    99,    35,    26,    87 };Now get the largest number.val.Max(z => z);Smallest numberval.Min(z => z);Second largest numberval.OrderByDescending(z => z).Skip(1).First();Second smallest numberval.OrderBy(z => z).Skip(1).First();The following is the code −Example Live Demousing System; using System.Linq; public class Program {    public static void Main() {       var val = new int[] {          99,          35,          26,          87       };       var maxNum = val.Max(z => z);       ... Read More

Authentication Options in SAP HANA While Adding New System

Anil SAP Gupta
Updated on 22-Jun-2020 09:31:22

148 Views

There are different authentication methods that you can use −Authentication by Operating System UserAuthentication by database userConnect using SSL

Using an Aggregate Function in SAP HANA

Anil SAP Gupta
Updated on 22-Jun-2020 09:30:49

426 Views

You can use an aggregate function to get the same. Common aggregation functions are −Average() − returns the average of the numeric values in a given columnSelect Average (Sales) from table_name where Column1=’ABC’; 

What is an Object Pool in C#

George John
Updated on 22-Jun-2020 09:30:43

1K+ Views

Object pool is a software construct designed to optimize the usage of limited resources. It has objects that are ready to be used.The pooled objects can be reused. The object pooling has two forms −On activation of the object, it is pulled from pool.On deactivation, the object is added to the pool.Configure object pooling by applying the ObjectPoolingAttribute attribute.This is applied to a class deriving from the System.EnterpriseServices.ServicedComponent class.To understand how a pool behaves, the Diagnostics class has informational properties. Through this, you can check the behavior under dissimilar scenarios.The usage of Object pool can be understood when a part ... Read More

Count Character Occurrences in a String using C#

karthikeya Boyini
Updated on 22-Jun-2020 09:30:26

981 Views

Let’s say our string is −String s = "mynameistomhanks";Now create a new array and pass it a new method with the string declared above. This calculates the occurrence of characters in a string.static void calculate(String s, int[] cal) {    for (int i = 0; i < s.Length; i++)    cal[s[i]]++; }Let us see the complete code.Example Live Demousing System; class Demo {    static int maxCHARS = 256;    static void calculate(String s, int[] cal) {       for (int i = 0; i < s.Length; i++)       cal[s[i]]++;    }    public static void Main() { ... Read More

CSS overflow: auto

seetha
Updated on 22-Jun-2020 09:30:23

447 Views

The CSS overflow: auto, adds a scrollbar only when it's needed, unlike overflow:scroll. You can try to run the following code to implement CSS overflow: auto property:ExampleLive Demo                    div {             background-color: orange;             width: 250px;             height: 45px;             border: 2px solid blue;             overflow: auto;          }                     Heading       Overflow property used here. This is a demo text to show the working of CSS overflow: auto. This won't hide the content. A scrollbar would be visible, only if needed.     Output

Advertisements