Skip to main content

Posts

Showing posts from November 18, 2020

Generate CSV values easily in C# , String Manipulation in C#

Suppose you are having a List<String> and you are in need to generate a Comma Separated Value (CSV) from this with single quotes attached   Say We need to dynamically generate a simple SQL Select statement from a Order table and the filter criteria would be like this   Select New ('NO') Orders, Active ('AO') Orders and Successful ('SO') Orders Let's we have a Status Codes in a List<String>   The desired output SELECT * FROM ORDERS WHERE STATUS IN ('NO', 'AO', 'SO')   Traditional Solution   TraditionalSolution(StatusCodes);   private static void TraditionalSolution( List < string > StatusCodes) { // Traditionally what we will do is // Loop through the List and generate a SQL Statement   string OutputSQL = "SELECT * FROM ORDERS WHERE STATUS IN (" ;   int Count = StatusCodes.Count(); foreach ( string SingleStatusCode in StatusCodes) { OutputSQL += "

Simple Object Oriented Programming (OOP) Concepts with Examples Part 1

Let's begin with a simple base class and derived class, and explain how the both are working. Let's create a Base Class with the constructor taking no parameters,         class BaseClass1         {             public BaseClass1()             {                 Console .WriteLine( "In BaseClass1 constructor" );             }         }    And Creating a Derived Class DerivedClass1   which inherits Base class BaseClass1           class DerivedClass1 : BaseClass1         {             public DerivedClass1()             {                 Console .WriteLine( "In DerivedClass1 constructor" );             }         } And in the Main Function just create an object for the BaseClass1              BaseClass1 BC1Obj = new BaseClass1 (); Now the output will be                 In BaseClass1 constructor While trying to create another object for                 BaseClass1 BC1Obj2 = new DerivedClass1 (); Now the output will be