Steadhaven
Explore posts from serversNo Main and class confusion in newer C# versions
I am confused about the newer C# versions... When I make a console app, it just starts like so:
As you see, theres no class or Main method. In Java, and old C# if I am correct, we always have to have a class with a main method for our code to run.
However, it seems that newer C# versions doesn't require this. Yet my confusion is:
- OOP is rather valuable in a lot of scenarios, so what do we do without classes?
- Is the Main method just in the first file we create? or where is it? it seems to run without it
52 replies
Which of these two books would you recommend to dive deep into?
Hi,
I know other languages like Java, Scala, and some web dev like React/Next.js/TypeScript.
I am now in the pursuit of learning C#.
I prefer to read books as its much easier and faster for me than a computer screen, also I can more readily take notes inside the book (yeah I know some hate it).
I found these two modern and updated books:
- Essential C# 12.0 by Mark Michaelis: https://www.amazon.com/Essential-12-0-Addison-Wesley-Microsoft-Technology/dp/0138219516
It doesn't have ratings yet because its so new, but the old one in its series got 4.7 rating score from 15 ratings: https://www.amazon.com/Essential-C-8-0-Mark-Michaelis-ebook/dp/B08Q84TH84
- C# 12 and .NET 8 – Modern Cross-Platform Development Fundamentals: Start building websites and services with ASP.NET Core 8, Blazor, and EF Core 8 by Mark J. Price: https://www.amazon.com/12-NET-Cross-Platform-Development-Fundamentals/dp/1837635870
As you see it also has 4.7 rating score from 51 ratings, but its been out 1 month more.
5 replies
IDisposable and using keyword?
I am trying to understand
using
and IDisposable
.
It seems that we can attach IDisposable
to any class, which gives us a method called Dispose
that we have to implement. This dispose method is automatically run and does whatever is specified, whenever we shutdown/remove a class.
And using
is something we use for IDisposable
classes only it seems. And somehow the using
keyword would then know what to do when we shutdown the class...
1- I can kind of understand IDisposable, but want to know if my explanation is correct
2- What does it mean that a class is shutdown/removed? how can I do this in code?
3- the using keyword (as I tried to explain above) still make almost no sense, and I am even sensing it can be used without IDisposable
(If needed for other language examples then I know Java/Scala/React a bit, but prefer C# explanation :) )6 replies
Do while with int.TryParse - how?
I am trying to create a C-sharp program, that ask the user to pick a number between 1 and 3. It will then use that number to print one of three names I have in an array. This is how far I got:
I wanted the do-while to continue until the nubmerText is an actual number I can parse to Int, but also then be a valid number from 1-3 but I am kind of confused as to how to proceed.
35 replies