TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Maha
NA
0
325.2k
Inconsistent accessibility continue
Aug 21 2013 4:20 PM
http://www.c-sharpcorner.com/Forums/Thread/225889/inconsistent-accessibility.aspx
I wish to know whether it is possible to demonstrate behavioural pattern mentioned of FlavorScoop() method by an example.
Your explanation about using access modifier (14th thread of Inconsistent accessibility)
After this (single module) assembly has been compiled,
it could (in theory) be added as a reference to another assembly
. If code in the latter assembly wanted to call the FlavorScoop method, it would have problems in doing so because it wouldn't have access to the IceCreamCone class.
The compiler is therefore ensuring that these problems won't arise by flagging it as an error now.
using System;
public class Program
{
public static void Main()
{
IceCreamCone vanilla2 = new IceCreamCone("Vanilla", 2);
IceCreamCone chocolate1 = new IceCreamCone("Chocolate", 1);
FlavorScoop(vanilla2);
FlavorScoop(chocolate1);
Console.ReadKey();
}
public static void FlavorScoop(IceCreamCone icc)
{
Console.WriteLine(icc.GetFlavor() + " flavor" + ", " + icc.GetScoops() + " scoop");
}
}
class IceCreamCone
{
string flavor;
int scoop;
public IceCreamCone(string flavor, int scoop)
{
this.flavor = flavor;
this.scoop = scoop;
}
public string GetFlavor()
{
return flavor;
}
public int GetScoops()
{
return scoop;
}
}
Reply
Answers (
31
)
Array Sequence TimeStamp Validation
Protected vs. Private Access