Let’s look at the Car class we created:
Public Class Car Private m_make as string Private m_model as string
Public Property Make() as string Get() return m_make End Get Set(ByVal Value as string) m_make = Value End Set End Property
Public Function Drive() as string if m_make = "Oldsmobile" then return "Chicago" else return "Toledo" end if End Function End Class
First lines of code are fields. Fields are simply variables defined within a class. They can be private like we have in the Car example, or they can be public.
Ideally, you should never use Public Fields, but rather use Public Properties instead. We'll talk about that more in a moment, but let’s add three more BEST PRACTICEs to our ongoing list:
BEST PRACTICE: Instead of Public Fields, use Public Properties. As a general rule, keep as many fields and methods private, and make them public only if there is a reason to do so.
Supplemental Readings for the Express Edition Videos Copyright © 2005 LearnVisualStudio.NET