Skip to content

Comment on Top Mistakes that C# Programmers Make

Comments

11. Not buying Resharper.

On a separate note I much prefer the lambda style Linq to the SQL style. I think it easier to work with, but I'm not sure why.

With regard to classes versus structs. I rarely use structs. What are the real world use cases for them over classes?

When I was learning C++, it was conveyed that structs were more for combining like data that didn't necessarily require a class because it had a bit less overhead. An example would be a lot of variables that are related, but have no methods (such as a creating a node data structure for making an implementation of a linked list or tree).

Though the above was related to C++, that's generally when I use structs for C# as well.

I think a real world use case for structs is for avoiding allocating objects in performance critical code [1] - though I'm not sure it is required in the vast majority of code.

[1] http://stackoverflow.com/questions/22894877/avoid-allocation...

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.