Tim you might not ever read this comment, but I just want to tell you how incredibly thankful I am that I found your channel about 3 years ago. You have helped me develop into a very good senior programmer, I have a better job now with more money and I can't begin to tell you how much better my life has become after going through all your courses. I truly mean it. You're an incredible teacher.
It is October 2024 and this video and many others you´ve made have been very helpful. I am migrating from C++ and Visual Basic .NET and this is the best content I´ve found so far in the internet. I truly appreciate it.
I have been a c# dev for over 10 years and I still enjoy your content. Especially with interview questions I have proper answers for interviewers. Thanks man you’re the best
31:32 - "Why not make everything public" I love the way Tim explains the same thing from different angles numerous times to solidify and crystalize the knowledge transfer so as to make it CONCRETE! This is a man who taught this stuff at the college level for more than 5 years. He's not only knowledgeable and understandable, but he really knows HOW TO TEACH. My only complaint is that he doesn't teach EVERYTHING.
That part is actually a lot of bullshit. Since when having the CC number as public is a security risk but having it private isn't? lol, I will easily get private stuff using reflection. The point of private stuff is to organize your code and your APIs, some stuff is too much implementation detail that it doesn't make sense to expose it, what it makes sense to expose you set it as public or internal, depending on what is your intention.
There are those who gives meaning, and there are those who gives people a chance at a career for better lives, you are both, thank you so much Tim Corey, thank you.
Thanks for the vids, Tim! Whenever I google something specifically C# related I now add your name to it since you explain things so well. Thank you so much for providing amazing, clear, and useful explanations on these topics.
Thank you for this explanation. I took C++ in college many years ago but never really pursued a developer type career. Recently I have been rethinking that choice and it's clear videos like this that make a big difference for me. This not only explains the What and How for scope, but continues to explain Why it's important.
Thanks Tim. Appreciate all the time and effort put into this video to explain the concept of modifiers. Like your pace, the simple examples that make your videos stand out. What I like more is you getting into details when needed, explaining the WHY and WHERE - a developers dream come true (saving my search on google).
⭐️⭐️⭐️⭐️ star tutorial. You are the best in being capable to explain all the logic accurately and simply. This helps one to understand the complex logic easily and practicing helps a lot in consuming the knowledge better. Your approach in explaining first alongside showing it practically helps to visualise and consume the topic better. I'm more inclined to learn ideas and logics visually and this assited me to dive deep. Thank you for all your efforts. I will surely, go through all the topics in advanced C# playlist and expecting to evaluate and improve my existing skills.
Best explanation of access modifiers, period. Thanks Tim, this video was massively helpful in helping me understand the use cases for each of these modifiers.
Tim, thank you for your videos and explanations. I've seen others who only explain the what and the how. You also explain the why with real world examples and I really appreciate that. Keep up the good work!
Thank you so much for clarification Tim! It made it more clear. However I think that those private protected and protected internal are really exotic ones and I can’t imagine the case where one can need those access modifiers.
Awesome Tim, to be honest the hardest part for me is what you touched on at the end, piecing a project together and mapping things together, that's been one of the most confusing things in my journey to learn C# and .NET, can you recommend any vidoes that might help with this? Stuff like this one is great, where you have multiple assemblies and explain the modifiers and how they work in the different assemblies. Thought I'd ask if you have any videos on overall project structure and mapping things out, or the best practices for building different types of apps etc. especially web apps! Thanks for your help!
Tim you can start the story telling by saying access modifiers are a sort of selectivity and visibility based on functional needs of a system and describe the modifiers by giving context domain like the components of a car. This will help c# developers visualize the use case.
Hey Tim, thanks a bunch for your comprehensive explanation about access modifiers, and for the time and effort you put into this 💪 I understood that the DRY principle is one of the most simple yet powerful principles to learn. What other principles do you recommend? Thanks in advance
I don't believe so on RU-vid. I cover that in my Foundation in C# course series. Basically, use properties whenever you need to make the data available outside the class (no public variables). As for static methods, you use them in a few cases, but mainly when you don't need to use them only in a specific instance of a class.
@@IAmTimCorey sorry if I was bit of a ambiguous. What I meant to ask was when to use static methods, static variables and static properties? I see those sometimes in my company's code base and they are sometimes a pain in the ass. Like if some configurations area loaded from config (basically xml) file to a private static variable, in order to get those configs to change for the web application, I have to restart the whole damn application. Sometimes I change them to public static variables so that I can make them changeable from other places without restarting the whole app.
Hi Tim. As all your videos this one is just amazing however I have a question about one more ?modifier? - static. How do I know where and when should I put it and what are the consequences of it? I don't know if You already covered it somewhere else - if so than sorry for asking in the wrong chapter. Thank You for the video once more.
I cover that in the Foundation in C# course series, but I don't think I have a specific video of it on RU-vid. Basically, static means you cannot instantiate the class. You get one copy that everyone uses instead of creating instances. Default to instantiation unless there is a really good reason to use static.
I just stumbled over your channel and so far really enjoy it. A thought about accesss modifyers: Would't event be an access modifyer which makes a field of a delegate type accessible externally with += and -= only? I at leas like to think about it that way.
I used to think why bother I’m the only developer, who cares if it’s public or private or protected for a small app _ then my friend ripped apart my app showing me all my classes using reflection and a decompiler. Lesson learned!
I've only known your channel for a few days but I've already watched a lot of your videos. Thank you for your great videos, even after many years as a programmer I can still learn something from you. I have a question for which I haven't found a video from you yet, but maybe I just haven't watched the right video yet. I would be interested to know if you think it makes sense to use private properties instead of private fields? In the application framework in which I mainly work, it has become common practice that private fields are hardly ever used. And I still don't know whether that makes sense or not. Or whether it actually makes a difference. Many thanks and best regards Peter
There are only a couple of reasons I can see to use private properties: 1 - If you are expecting to make them public someday. 2 - If you want to limit the input/output of them. Otherwise, I do not see the benefits. I would ask them what benefits the private properties give them over private fields.
@@IAmTimCorey thanks a lot for your reply! It is so great that you take the time to answer all these questions. I will ask them because in most cases it really makes no sense to me - thanks!!
Thanks for that. I have to confess that I was guilty about using "public" and creating "global public" variables. I am learning to rethink things and make the accessing more stricter. I am working on redoing access modifiers. There was one class that I saw that uses "Sealed". Is that a popularly used one or one that is being discontinued?
This is one of those edge patterns that is only useful in a few scenarios. The basic idea is that you separate out your database read code from your database write code (vast over-simplification). There are very few cases where this separation adds value to your application but there are a lot of cases where you would cause more complexity without added value. There is a case for it, but I shy away from things that people will watch and then try to implement. It is almost certain that they will be implementing it in the wrong situation if they try to do so with CQRS (it is valuable typically in a part of a large, complex application).
Job interviews are tough. The interviewer needs to identify the most skilled person for the job but that really is subjective. They try to make it objective but that gets you poor results at best.
Tim, is your main language C#? I think you really put out some great content. I'm at UNI studying towards MS stack and using a lot of your insights as an addition is so good to me. Thanks for your hard work, I hope you make plenty of money on it.
Right now, yes. However, that has fluctuated over the years depending on the needs of where I worked. It has almost always been a primary language of mine since it came out but I've worked heavily with JavaScript, SQL, C, C++, VB.NET, VB6, and more. Along the way, I've also worked in a bunch of secondary languages (Java, objectiveC, FoxPro, etc.) as well. The trick is to learn one language well and get really familiar with the concepts of development. Then you can much more easily switch languages because it is a similar expression of logic with just a change in syntax. The harder transitions are OOP to functional languages, but you still have a good base to work with.
Hi, Tim, when experimenting on my own in the Visual Studio, I notice that protected private also works, then I searched the web but no where to be found, could you explain a little? (I also realize that private internal equals internal, so there is no such thing) 🤠
It's probably me who didn't fully understand this, but isn't he making a mistake at 21:40? Shouldn't protected internal behave as internal in its own assembly and as protected for any other assemblies? And not the other way around as he is saying?
I think it's very easy to understand these , but for beginners it's better to offter a nested scope graph to explain these keywords's functional scope.
Just out of interest, do internal classes have any added benefits to a "normal" class (i.e a non-public class), or are "normal" classes marked internal by default.
Great video, as always! But maybe you can help me figure out... What's the default access state of a class? It is not public, but also not private. I've noticed that a class without any access modifier can be used inside the project(assemly), but not outside of it. So it looks like all classes are internal by default (if they have no other modifiers). Am I right?
*private* (outer) *protected* (inner) -> It behaves as *private* from outside the assembly and *protected* from inside the assembly *protected* (outer) *internal* (inner) -> It behaves as *protected* from outside the assembly and *internal* from inside the assembly
If your the only developer on a project is the private mindset that important? I was under the impression that once compiled methods wouldn't be accessible.
"An access modifier in C# specifies who can see and use a resource." Just what I was looking for. But nothing in the first part of video builds on this. What do I need to look for in order to find information about limiting access to private pages to the page owner?
Pages? Do you mean classes or are you talking ASP.NET? If the former, this video covers that. It walks through your options and which ones give who access. If the latter, that's a different technology.
@@IAmTimCorey No. I dont mean classes. And no, not ASP.NET. I need to let users create content and have them store that content and review it later. What kind of structure is less important, but i need to control the access. So pages, content, endpoints or what you want to call it, but data that I can "specify who can see and use".
So what you are looking for is authentication and authorization. I do have videos on that for ASP.NET MVC as well as the TimCo Retail Manager, which uses WebAPI and has auth on a WPF app.
The first is a field, the second is a property. You cannot bind to a field. You also cannot protect a field like you can with a property. Also, if you change a field in any way, it requires you to recompile all applications that depend on that field. This is not true with properties. The list goes on, but the basic answer is to not use public fields, only public properties.
Public and Private are definitely useful and necessary. Protect and Internal can be used to cover some edge cases, nice to have in real life. The other two are just dumb ideas in my opinion
Hi Tim, why don't you create courses on Udemy. Create a full project. Windows first, ASP.NET MVC second and then with that introduce SOLID principles, also including good programming techniques, add then WCF, WEB API and spread out using these projects as a basis for another course on MicroServices. Just a suggestion. I always pay for courses on Udemy and they are affordable. Thanks for this video. Take care.
I did offer a course on Udemy: www.udemy.com/course/which-aspnet-core/?couponCode=MOVINGSALE The experiment did not go well, unfortunately, and I won't be offering more courses on the platform. I see about 16% of the income of what I see on my site and no, the number of people who buy my course does not make up for it. Total income is about 30% of what I would get on my site and I more than double my support needs.
It is a modifier (like abstract, async, const, and more) but it is not an access modifier. Access modifiers determine who can see/use an item. Readonly doesn't restrict who can see it/use it but rather how it can be used.
@@josephmarsh5031 the keyword "readonly" is used to declare an immutable variable. i.e. A variable whose value, once assigned, cannot be changed. It's a modifier but not an access modifier!)
If you have not already, please consider checking out this video - ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-LUv20QxXjfw.html It is intended to help you assess where you are and the topics you need to add to your base skills. I hope it will help you fill in any gaps. My goal is to make becoming a developer easier and I hope I can help you be successful through your full journey!
Methods are inside Classes. Most people only use Public and Private Methods. Public and Private are Modifiers to Allow or Block Access to them. Tim shows how to use Methods that can share functionality and data. These are called ACCESS MODIFIERS. He talks about 13 different types.
I'm curious if you actually watched the video fully or just assumed you know it. For instance, do you understand the difference between protected internal and private protected? That's a simple concept to you? If so, I'm not sure why you were watching the video in the first place. And by the way, it only took 22 minutes to cover access modifiers as concepts (private, public, protected, private protected, and protected internal). The rest of the video was on how to use these in the real world and why we don't just use public and private for everything.
@@IAmTimCoreydon’t listen to such people Tim. You videos have an excellent length and explain things very thoroughly and I am sure that many people like me just like it that way.
I don’t understand why I don’t just make everything public so I don’t have to deal with this. I’m sure there’s a reason, I just don’t get it. This seems like extra work for nothing.
I think you meant to say, "Too complicated explanation". "To" is a preposition, whereas, "Too" is a Modifier, like Tim explains so well. You would use "To" to explain a place you are going like the place you are going to be free. Now, go, be free.