Sometime we are so busy "doing stufff" and miss the most basic concepts.
See the following code (LinqPad):
The key factor to consider here whether the code is going to compile. Actually it compiles and executes without any exceptions.
If you look closely you will see "friend.i.Dump()" and "friend.j.Dump()". This might be a cause for concern. This is because "i" and "j" are private members and how come we can call "f.i" in the "Add" method.
The "private" modifier indicates that the members can only be accessed within the same class. So in this particular case we are "inside" the "Friend" class and members are visible. Reference is here.
In order to prevent this confusion, simply use a property. That is simple and universally understood.
Labels
Android
Android part 1
Architecture
Article
ASP.NET
ASP.NET MVC
Async
AWS
AWS CLI
Baby
base image
Basic Concepts
Bridge pattern
C#
CallContext
Castle Windsor
CloudFormation
Command line
Continuous Integration
Coursera
Create IAM policy
Custom AMI
DaiySelfie
Design patterns
EC2
Encapsulation
Entity Framework
Geolocation
Google App Engine
HTML
HTML5
IAM
IIS
Improvements
Inheritance issues
Instance user data
Ioc
Java
JavaScript
KnockoutJs
Lanching EC2
Learning
Memory
MSBuild
OOP
pair programming
Perfmon
Pluralsight
Principals
Python
SimpleAPI
Sockets
Solutions Architect
SQL Server
SQS
State pattern
TFS 2010
Threading
Type Covariance
Udacity
Unit testing
Visitor pattern
WCF
Web Development
WebApi
Windows VMs
Tuesday 16 December 2014
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment