
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 33676 Articles for Programming

290 Views
A priority queue is held information with a priority value. It is an extension of queue.The item with the highest property is removed first when you try to eliminate an item from a priority queue.Let us see how to set priority queue −public class MyPriorityQueue where T : IComparable { }Now let us add an item. In the below example the items get stored in info, which is a generic list.Examplepublic class MyPriorityQueue where T : IComparable { private List info; public MyPriorityQueue() { this.info = new List (); } }

9K+ Views
To display single variable value in C#, you just need to use Console.WriteLine()Let us see an example. Here, we have displayed the value of a single variable “a” in a line −Exampleusing System; using System.Linq; class Program { static void Main() { int a = 10; Console.WriteLine("Value: "+a); } }To display multiple variables value in C#, you need to use the comma operator in Console.WriteLine().Let us see an example. Here, we have displayed the value of multiple variables “a” and “b” in a line −Exampleusing System; using System.Linq; class Program ... Read More

506 Views
To print your own font in C#, firstly construct −FontFamily objectFont ObjectThe FontFamily object sets the typeface like Arial, TimesNewRoman, etc, whereas the Font object sets the size and style of font.Let us create an Arial font style.FontFamily myFontFamily = new FontFamily("Arial"); Font myFont = new Font( myFontFamily, 20, FontStyle.Bold, GraphicsUnit.Pixel);Above, we have set the FontFamily object. The first parameter passed to the Font() is the FontFamily object “myFontFamily”, then comes the size of the font. The third argument sets the style.

265 Views
Mutational testing in C# includes verifying the quality of a test suite in the active solution. For this, use a tool called “VisualMutant”. It sets as an extension to the Visual Studio IDE. The following are the capabilities of a testing tool. The following are the features of VisualMutant, which is a mutation test tool − View modified code fragments in C#. Run NUnit and XUnit tests on generated mutants View details about any mutant right after the start of the mutation testing process It gives results as mutation score. Measure the quality of the test suite. To create ... Read More

1K+ Views
With method overloading, you can have multiple definitions for the same function name in the same scope. The definition of the function must differ from each other by the types and/or the number of arguments in the argument list.Let us see an example. In this the call would go to the method with a single parameter −Exampleusing System; class Student { static void DisplayMarks(int marks1 = 90) { Console.WriteLine("Method with one parameter!"); } static void DisplayMarks(int marks1, int marks2 = 95) { Console.WriteLine("Method with two parameters!"); } ... Read More

219 Views
ArrayList is a non-generic type of collection in C# that dynamically resizes.Let us see how to initialize ArrayList in C# −ArrayList arr= new ArrayList();Add an item to an Array List −ArrayList arr1 = new ArrayList(); arr1.Add(30); arr1.Add(70);Let us see the complete example to implement ArrayList in C#. Here we have two array lists. The 2nd array list is appended to the first list.Exampleusing System; using System.Collections; public class MyClass { public static void Main() { ArrayList arr1 = new ArrayList(); arr1.Add(30); arr1.Add(70); ArrayList arr2 = ... Read More

1K+ Views
To initialize a HashSet.var h = new HashSet(arr1);Above, we have set an array in the HashSet. The following is the array −string[] arr1 = { "electronics", "accessories”, "electronics", };The following is an example showing how to implement HashSet in C# −Exampleusing System; using System.Collections.Generic; using System.Linq; class Program { static void Main() { string[] arr1 = { "electronics", "accessories”, "electronics", }; Console.WriteLine(string.Join(",", arr1)); // HashSet var h = new HashSet(arr1); // eliminates duplicate words string[] arr2 = h.ToArray(); Console.WriteLine(string.Join(",", arr2)); } }

4K+ Views
To place spaces in between words starting with capital letters, try the following example −Firstly, set the string.var str = "WelcomeToMyWebsite";As you can see above, our string isn’t having spaces before capital letter. To add it, use LINQ as we have done below −str = string.Concat(str.Select(x => Char.IsUpper(x) ? " " + x : x.ToString())).TrimStart(' ');The following is the complete code to place spaces between words beginning with capital letters −Exampleusing System; using System.Linq; class Demo { static void Main() { var str = "WelcomeToMyWebsite"; Console.WriteLine("Original String: "+str); ... Read More

690 Views
Let’s say the following is the string −WelcomeAfter reversing the string, the words should be visible like −emocleWUse the reverse() method and try the following code to reverse words in a string −Exampleusing System; using System.Linq; class Demo { static void Main() { string str = "Welcome"; // reverse the string string res = string.Join(" ", str.Split(' ').Select(s => new String(s.Reverse().ToArray()))); Console.WriteLine(res); } }

459 Views
Format DateTime using String.Format method.Let us see an example −Exampleusing System; static class Demo { static void Main() { DateTime d = new DateTime(2018, 2, 8, 12, 7, 7, 123); Console.WriteLine(String.Format("{0:y yy yyy yyyy}", d)); Console.WriteLine(String.Format("{0:M MM MMM MMMM}", d)); Console.WriteLine(String.Format("{0:d dd ddd dddd}", d)); } }Above we have first set the DateTime class object −DateTime d = new DateTime(2018, 2, 8, 12, 7, 7, 123);To format, we have used the String.Format() method and displayed date in different formats.String.Format("{0:y yy yyy yyyy}", d) String.Format("{0:M MM MMM MMMM}", d) String.Format("{0:d dd ddd dddd}", d