Category Archive: C#

ToCommaSeparatedString() Extension Method for IEnumerable Collection in C#

Recently I have been using this extension method which would provide the comma separated string from a string collection. Thought it might be useful for sharing. Extension Method Use Use the namespace for… Continue reading

Sending HTML Mail in C#

In this post we would see how we can send a mail where the content is HTML in C#. To begin with, we need to use Microsoft.Office.Interop.Outlook assembly.   If you are having… Continue reading

Delete File to Recycle Bin in C#

In this post we would see how we delete the file to Recycle Bin. Using the File.Delete() method from System.IO namespace, would delete the file permanently from the system. However we could delete… Continue reading

GetValueOrDefault Method for Nullable Value Types in C#

Nullable Value Types? Value types in C# cannot have null value. However by using Nullable struct or ? we could achieve Nullability to value types. In the following example, both the statements are… Continue reading

DebuggerStepThrough Attribute in C#

Often when we debug, we unnecessarily step into (By Pressing F11) blocks we don’t require to debug. DebuggerStepThrough is the attribute which helps for this purpose. Example As you see in the following… Continue reading

Chaining Conditional Operator in C#

What is conditional operator? A conditional operator which is a ternary operator; takes the condition as first part, the second part is the value to be returned if first part is true and… Continue reading

Enumerable.Range in C#

Range is a static method defined in Enumerable class. The purpose of this method is to provide a collection of sequential numbers. The parameters required for the method are the start of the… Continue reading

String Number Parsing in C#

At some point of time, we need to parse a number which is represented in string format. C# has NumberStyles Enum which helps enormously for parsing. To proceed with the examples, you need… Continue reading

3 Part Format of Numbers in C#

What is a 3 part format? The 3 part format is used to show a positive, negative and zero value number. The string format has three parts. The first part corresponds to the… Continue reading

Creating Combination Enum in C#

What is Enum in C#? Using enum keyword, a set of enumerator list is created. The enumerator list contains constants. The following TextStyles enum has the following constants or enum values.   Typical… Continue reading

Accessing Internal Method Outside of Assembly in C#

What is internal in C#? It’s one of the keyword available in C# language. It means that, the members, classes and methods marked as internal are never exposed to other assembly. In this… Continue reading