Category Archives: C#

AutoMapper in C#

AutoMapper is an object-object mapper which allows you to solve the problem of manually mapping each property of a class with the same properties of another class. AutoMapper saves you the tedious effort of having to manually map one or more properties of such incompatible types. Before AutoMapper was introduced if we wanted to assign… Read More »

Explicitly implementation of Interface

In this post, We will learn how to implement multiple interfaces with same method name with example. When a class which has inherited an interface explicitly implements methods of that class is called explicit implementation.This method can now be accessed only through interface instance.They are useful in cases when a class inherits two interfaces and both… Read More »

Constructor in C#

Constructor is special method of a class that name is same as class name. Main use of constructors is to initialize private fields of the class while creating an instance for the class. Constructor is automatically invoked or called when an instance of that class is created. When you have not created a constructor in the class, the… Read More »

OOPS Concept

OOP is a paradigm that used for software development that have following principle. Object: An object is a real world entity that have physical existence in world. Class: a blue print of an object that describe the character and behavior of object. Abstraction: hiding the complexity and show the necessary data to the user. Encapsulations: wrapping up… Read More »

Enumeration in C#

An enumeration is a set of named integer constants and declared by enum keyword. They are value data type in other words it has their own value or can not inherit. Enumeration list is seperated by comma and by default first enumeration list is 0(or starts with zero). syntax: enum <enum_name> { enumeration_list }; Example:… Read More »

How to validate XML with XSD file in using c#

Here we will learn how to validate XML  with XSD file in using c# with example. //In below example, we are passing three parameters: //xmlString: XML String //XSDPath: Path of XSD file //NamespaceXML: Namespace of xml public static bool IsValidXml(string xmlString, string XSDPath, string NamespaceXML) { bool isValidXML = true; List<string> errrorMssage = null;… Read More »

XML Serialization and Deserialization in C#

Here we will learn how to implement XML serialization and deserialization in using c# with example: First, we will do serialization of an object as below example //Pass an object of a class public static string SerializeObject(T Request) { string xmlString = string.Empty; MemoryStream memoryStream = null; XmlSerializer xs = null; XmlTextWriter xmlTextWriter =… Read More »

Yield Keyword in C#

yield keyword is used for customized iteration in a collection. It is used inside an iterator block which return iterator type. It can not be used directly inside Main method which is void type. Uses of yield keyword : No need to create temporary list. As it returns value back to caller for every match… Read More »