Tips

Programming Tips

Simple Decryption in C#

As my previous tips in C# this is simple decryption algorithm. Here we are using SHA1 algorithm for decryption. It can be MD5. The code is self explanatory.

It is very simple decryption method. However there are many other methods exists in C# that you can use to encrypt and decrypt. Still I can guarantee it is safe.

1 string passPhrase = "Pas5pr@se"; ...

Simple Encription in C#

Following is simple encryption algorithm we can use in c#. It is simple and basic algorithm. Here we are using SHA1 algorithm for encryption. It can be MD5. The code is self explanatory.

It is very simple encryption method. However there are many other methods exists in C# that you can use to encrypt and decrypt. Still I can guarantee it is safe.

1 ...

Week Number From Date

Sometimes while working with calculations based on week number of the year, we required to get week number from the current date or specific date.

It is great help if the code is available on the net easily.

In C# we can use Calendar and CultureInfo class of Globalization namespace to get week number from any date.

1DateTime date = DateTime.Now;

System.Globalization.CultureInfo cult_info = System.Globalization.CultureInfo.CreateSpecificCulture("no");

System.Globalization.Calendar cal = cult_info.Calendar;

int weekNo = ...

Loop Through Enum in C#

While programming in C# we frequently requires to loop through the enums to fetch all the elements reside in enum, either Names or Constant Values.

So, I think it is very useful if the code is readily available on the net.

Following is the code for the same. In this example I have defined enum EmployeeType which defines different employee types. And then is the code to enumerate through all the candidates …