String conversions in C#

Introduction

This post will contain small code snippets that will convert a string to different types like a datetime,enum etc…

string to enum

The below snippet will convert string to an enum value.

string to DateTimeOffset

The below snippet will convert string to DateTimeOffset object. If the string cannot be converted then return current DateTimeOffset.