- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
George John has Published 1167 Articles
George John
319 Views
To match all digits in a string, use C# Regex.Firstly, set a string with digits −string str = "These are my marks: 90 out of 100!";Use the following regular expression to get digits in a string −@"\d+"The following is the code −Example Live Demousing System; using System.Text.RegularExpressions; namespace Demo { ... Read More
George John
473 Views
The position: fixed; property allows you to position element relative to the viewport. You can try to run the following code to implement CSS position: fixed;ExampleLive Demo div{ position: fixed; ... Read More
George John
358 Views
The Any() extension method is part of the System.Linq namepspace. Using this method, you can check whether any of the elements matches a certain condition or not.Firstly, set an array with elements −int[] arr = { 6, 7, 15, 40, 55 };The following is an example. It checks whether any ... Read More
George John
83 Views
To create a tuple, use the Tuple.Create method.Here we have set a tuple with a string and int −var myTuple = Tuple.Create("marks", 100);The following is an example that creates a tuple using Tuple.Create and displays the elements in a single line in C# −Example Live Demousing System; class Demo { ... Read More
George John
506 Views
Use the RootDirectory property to get the name of the root directory.Firstly, use DriveInfo to set the drive for which you want the root directory −DriveInfo dInfo = new DriveInfo("C");Now, the RootDirectory gives you the result −dInfo.RootDirectoryExampleHere is the complete code −using System; using System.Linq; using System.IO; public class Demo ... Read More
George John
830 Views
Use the Aggregate method in C# to perform mathematical operations such as Sum, Min, Max, Average, etc.Let us see an example to multiply array elements using Aggregate method.Here is our array −int[] arr = { 10, 15, 20 };Now, use Aggregate() method −arr.Aggregate((x, y) => x * y);Here is the ... Read More
George John
133 Views
Use the orderby leyword to sort a list in ascending or descending order.The following is the list −List myList = new List(); myList.Add("truck"); myList.Add("bus"); myList.Add("bicycle"); myList.Add("motorbike");Now let us sort the list in descending order −myLen = from element in myList orderby element.Length descending select element;Here is the complete code −Example Live ... Read More
George John
2K+ Views
Stopwatch is a class in C# to measure the elapsed time. Use it to calculate the time a function took to execute. It is found under System.Diagnostics.To get the elapsed time, firstly begin the Stopwatch −var sw = Stopwatch.StartNew();For elapsed ticks −long ticks = sw.ElapsedTicks;Let us see an example −Example Live ... Read More
George John
602 Views
The Ulong type in C# is an alias to the System.UInt64 type. It is an Unsigned integer.Set the Ulong type −ulong val = 7712059531;To get the minimum and maximum value for Ulong type −Console.WriteLine(ulong.MaxValue); Console.WriteLine(ulong.MinValue);Here is the complete code −Example Live Demousing System; using System.Threading; using System.Diagnostics; public class Demo { ... Read More
George John
10K+ Views
The KeyValuePair class stores a pair of values in a single list with C#.Set KeyValuePair and add elements −var myList = new List(); // adding elements myList.Add(new KeyValuePair("Laptop", 20)); myList.Add(new KeyValuePair("Desktop", 40)); myList.Add(new KeyValuePair("Tablet", 60));Here is the code to learn how to work with KeyValuePair and display the keys ... Read More