- 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
Found 34486 Articles for Programming
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
352 Views
StringTemplate class is used to parse the format string, so that it is compatible with String.Format. The StringTemplate class comes under the NString library that has extension methods. These methods makes string manipulations easy to use like.IsNullOrEmpty() IsNullOrWhiteSpace() Join() Truncate() Left() Right() Capitalize()StringTemplate.Format is better than String.Format since it is more readable and less prone to errors.The order of the values can be easily formatted. The values are formatted in a way similar to String.Format, but with named placeholders instead of numbered placeholders.The following is a sample −string str = StringTemplate.Format("{ExamName} will held on {ExamDate:D}", new { p.ExamName, p.ExamDate }); ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
704 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
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
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
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
390 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
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
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
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
6K+ 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
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
10K+ 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
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
1K+ Views
Take two arrays:int[] arr2 = new int[5]; int[] arr3 = new int[5];Now, if the array element gets the remainder 0 on dividing by 2, it is even. Get those elements and add in another array. This loops through the length of the array:if (arr1[i] % 2 == 0) { arr2[j] = arr1[i]; }In the else condition, you will get the odd elements. Add them to a separate array and display them individually as shown in the below example:Example Live Demousing System; namespace Demo { public class Program { public static void Main(string[] args) { ... Read More
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
3K+ Views
Let’s say you need to get the value of 10 dollars in INR.Firstly, set the variables: double usd, inr, val;Now set the dollars and convert it to INR.// how many dpllars usd = 10; // current value of US$ val = 69; inr = usd * val;Let us see the complete code −Example Live Demousing System; namespace Demo { public class Program { public static void Main(string[] args) { Double usd, inr, val; // how many dpllars usd = 10; // current value of US$ val = 69; inr = usd * val; Console.WriteLine("{0} Dollar = {1} INR", usd, inr); } } }Output10 Dollar = 690 INR
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
386 Views
We have set an array and a dictionary to get the distinct elements.int[] arr = { 88, 23, 56, 96, 43 }; var d = new Dictionary < int, int > ();Dictionary collection allows us to get the key and value of a list.The following is the code to display distinct elements of a given integer array −Example Live Demousing System; using System.Collections.Generic; namespace Demo { public class Program { public static void Main(string[] args) { int[] arr = { 88, ... Read More