Implicit – Explicit Conversion Operators


The explicit keyword declares a user-defined type conversion operator that must be invoked with a cast. Where as the implicit keyword is used to declare an implicit user-defined type conversion operator. Use it to enable implicit conversions between a user-defined type and another type, if the conversion is guaranteed not to cause a loss of data.

I would use a self explanatory example to describe Explicit. Continue reading Implicit – Explicit Conversion Operators

Advertisements

Quickly convert Comma Separated Values to Dictionary


If you are getting some sort of CSV let’s say some sort of configurations or data object or whatever the case may be, my strategy is : “If you can not deserialize ’em, structure ’em !”

And here is one of the possible scenario :

TIP :

If you’re dealing with more complex scenario, you might wanna consider using Tuple or Jagged Tuple ! ( What is it ? )

Continue reading Quickly convert Comma Separated Values to Dictionary

Remove Duplicates from stack (?)


Well first off, stack is not for that ! I mean what is the point of having list / collection / etc vs stack as different data structures ? But if still if you want to do so you can  Continue reading Remove Duplicates from stack (?)

Remove strings between double quotes


How many times you have to bullet proof your application against some bad or junk data ? Sometimes we might not have anticipated some scenario until quite a while. And this can quite possible if your application relies on some other program ( data from web service, some sort of incoming XML or something like that )

Well LINQ is your friend !

Just a heads up :

Going forward I shall try to maintain all string manipulation related posts ALSO under ‘string-manipulation‘ tag, just if that helps you drill down the content better. Cheers ! 😉

Continue reading Remove strings between double quotes

Quickly Clean-up Blank lines from a multi-line String


Scenario : At the time of consuming data from another application or program, one of the frequent issue is data in and data out ! I was working for similar scenario the other day where a flat was generated and then another program had lexical parser and would generate tokens etc. Long story short, in a typical workflow we had blank lines and they were causing issue. Very simple issue … once this stupid thing is identified and verified being the actual culprit !

Let’s take a look :

Continue reading Quickly Clean-up Blank lines from a multi-line String

C#


Below are some code snippets / recipes that I have had prepared for myself and I thought of sharing with ya’ll as a firs post in C# category. If you do not find one that you are looking for or want more, just drop me a request or comment below, I’d try to address the request.

Example Description Download
Global Variables in C# Different scenarios as your requirement and need zip
Text to SQL Server Read a text file and insert all records in SQL Server. zip
Update combobox items according to selection of column-name in other combobox zip
MySQL(SQL Server) To MsAccess Copy table of Ms-Access from the data of the MySQL zip
(Basic) Reading Ms-Excel spreadsheets Reading data from Excel sheets using C# zip
Updating Ms-Excel spreadsheets Updating data of Excel sheets using C# zip
Accessing .config file The app.config can be used to access some setings (like conn string) anywhere in the project zip
MySQL (SQL Server) database to CSV Convert record set from MySQL query to csv file zip
String Delimiter Various illustrations in a single project, demonstrating ways to use the String.Split() function zip
Date – Times Gets the beginning and ending dates of

  • This Week
  • Last Week
  • This Month
  • Last Month
  • Last 6 Months
  • This Year
  • Last 3 Years
zip
Update/Delete CSV Here is the work around for Updating / Deleting records from CSV, which usually is just a file IO operation otherwise zip
json json in C# using JSON .NET & LINQ zip
json serialization serialization/de-serialization of json zip
Stateful iterations By using yield keyword, difference b/w IEnumerable and IEnumerator zip

Unobtrusive validation from scratch in ASP.Net 4.5 WebForms


Jupaol’s blog post

Free Web based IIS like manager


http://servant.io/

http://blog.servant.io/