c# - Convert string in to Datetimeoffset -


i having string has data 6/30/2016 12:00:00 , using below code

public string convertdatecreated(string datecreated) {   system.globalization.cultureinfo provider = system.globalization.cultureinfo.invariantculture;   return datetime.parseexact(datecreated, "mmddyyyy", provider).tostring("yyyymmdd"); }  

i not sure how convert them in datetimeoffset type using tryparseexact can inserted in ms sql database

the datetimeoffset object has constructor takes datetime object, once have parsed can simply:

var dto = new datetimeoffset(datecreated); 

Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -