
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 2587 Articles for Csharp

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.

264 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

217 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

688 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); } }

456 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

1K+ Views
Serialization converts objects into a byte stream and brings it to a form that it can be written on stream. This is done to save it to memory, file or database.Serialization can be performed as −Binary SerializationAll the members, even members that are read-only, are serializedXML SerializationIt serializes the public fields and properties of an object into XML stream conforming to a specific XML Schema definition language document.Let us see an example. Firstly set the stream −FileStream fstream = new FileStream("d:ew.txt", FileMode.OpenOrCreate); BinaryFormatter formatter=new BinaryFormatter();Now create an object of the class and call the constructor which has three parameters −Employee ... Read More

584 Views
To reverse a string, use the Array. Reverse() method.We have set a method and passed the string value as “Henry” −public static string ReverseFunc(string str) { char[] ch = str.ToCharArray(); Array.Reverse(ch); return new string(ch); }In the above method, we have converted the string into character array −char[] ch = str.ToCharArray();Then the Reverse() method is used −Array.Reverse(ch);