CSharp: `error CS0103: The name 'DateTimeOffset' does not exist in the current context`

Published: 2020-04-20 12:07:52 -0400 -0400

Reading time: 1 mins (84 words)

Tags: csharp error datetimeoffset


I’m building a project in C# and trying to use the DateTimeOffset class. However, I’m getting the error CS0103: The name 'DateTimeOffset' does not exist in the current context. How do I fix this?


Errors like this usually signal that you’re not importing a required library that defines the object / reference. In this case, the DateTimeOffset class is defined in the System library, so to fix this you can simply add an import at the top of your file:

using System;

About the Ham

Hi I'm Hamilton and I wrote / built this! I like doing lots of things, but mostly I like to build (and then share those buildings). Some things I'm currently building: art, software, and prose. To stay up-to-date with my latest buildings, subscribe to my email list or follow one of my many other accounts. #buildit #shipit #justhamit

comments powered by Disqus