# .NET 6 new program style vs .NET 5 old program style

**URL:** <https://forum.codewithmosh.com/t/net-6-new-program-style-vs-net-5-old-program-style/9927>\
**Category:** C#\
**Created:** [January 13, 2022, 7:48pm UTC](https://forum.codewithmosh.com/t/net-6-new-program-style-vs-net-5-old-program-style/9927 "2022-01-13T19:48:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ctslater](https://avatars.discourse-cdn.com/v4/letter/c/73ab20/32.png) [@ctslater](https://forum.codewithmosh.com/u/ctslater)\
**Post date:** [January 13, 2022, 7:48pm UTC](https://forum.codewithmosh.com/t/net-6-new-program-style-vs-net-5-old-program-style/9927/1 "2022-01-13T19:48:33Z")

</div>

Greetings and salutations!

I have some basic knowledge of programming, but a complete beginner with C#.

I’m a bit confused with the new vs old program style.

I’m using VS Studio community with .NET6 and from what I understand the term top-level statements means the compiler generates the namespace, class, and method elements for the main program. Mostly works, but sometimes this creates errors when I try to follow along.

Should I go back to .NET5 or I’ll be ok with .NET6?

Besides the Windows docs, I didn’t find much info on this.

Thanks!

---

<div class="post-metadata">

**Author:** ![eelsholz](https://avatars.discourse-cdn.com/v4/letter/e/439d5e/32.png) [@eelsholz](https://forum.codewithmosh.com/u/eelsholz)\
**Post date:** [January 14, 2022, 2:05am UTC](https://forum.codewithmosh.com/t/net-6-new-program-style-vs-net-5-old-program-style/9927/2 "2022-01-14T02:05:34Z")

</div>

I think you should be able to use the old style even in .NET6. Have you tried it?

---

<div class="post-metadata">

**Author:** ![ctslater](https://avatars.discourse-cdn.com/v4/letter/c/73ab20/32.png) [@ctslater](https://forum.codewithmosh.com/u/ctslater)\
**Post date:** [January 14, 2022, 2:18pm UTC](https://forum.codewithmosh.com/t/net-6-new-program-style-vs-net-5-old-program-style/9927/3 "2022-01-14T14:18:39Z")

</div>

Thanks for the reply!

Hey I think you’re right. Seems I can create the project in .NET5, then change the framework settings to .NET 6. Should be all good.

Cheers,

---

<div class="post-metadata">

**Author:** ![TomVer](https://avatars.discourse-cdn.com/v4/letter/t/bc8723/32.png) [@TomVer](https://forum.codewithmosh.com/u/TomVer)\
**Post date:** [March 1, 2024, 1:21am UTC](https://forum.codewithmosh.com/t/net-6-new-program-style-vs-net-5-old-program-style/9927/4 "2024-03-01T01:21:52Z")

</div>

Interesting discussion

---

<div class="post-metadata">

**Author:** ![UniqueNospaceShort](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/uniquenospaceshort/32/1814_2.png) [@UniqueNospaceShort](https://forum.codewithmosh.com/u/UniqueNospaceShort)\
**Post date:** [March 1, 2024, 9:28am UTC](https://forum.codewithmosh.com/t/net-6-new-program-style-vs-net-5-old-program-style/9927/5 "2024-03-01T09:28:42Z")

</div>

Hi,  
That would be interesting to have more details on what is not working for you with Top-Level Statement syntax.

Just remember that in the _Program.cs_ file, this is like you’d be coding within the `Main` method.

You cannot define static methods in the same file for instance. You’ll need to import extra code from another file.

Cheers.
