Skip to main content

Posts

C# Coding Best Practices, Coding Standards : Quick Guide

C# Coding Best Practices, Coding Standards A Quick table to identify when to use what.   Starts With Writing Style Example Class Any Pascal Case MyClass Struct Any Pascal Case MyStruct Interface I Pascal Case IMyInterface Private Fields _(Underscore) Camel Case _userName Internal Fields _(Underscore) Camel Case _userName  For more detailed information see here

Beginners Coding Challenge : C# Program to convert the list of string to CSV with quotes

Beginners Level: C# Program to convert the list of string to CSV with quotes  There may be the situation where we need to build any dynamic SQL queries to fetch the data programmatically, Example: SELECT * FROM ORDERS WHERE DELIVERY_LOCATION IN ('Sydney', 'Singapore', 'Tokyo', 'Jakarta'); For this we need to have  // Program to convert the list of string to CSV with quotes static void Main( string [] args) {   List < string > LstCities = new List < string >();   LstCities .Add( " Sydney "); LstCities .Add( " Singapore "); LstCities .Add( " Tokyo "); LstCities .Add( " Jakarta ");     string InClause = string .Format( "'{0}'" , string .Join( "','" , LstCities )); Console .WriteLine( InClause ); Console .ReadLine(); } This will print 4 city names in the following format  ' Sydney ', ' Singapore ', ' Tokyo ', ' Jakarta '