18
Answers

Inconsistent accessibility

Maha

Maha

11y
1.7k
1
In the following program, if both are "public" error signal is saying that Inconsistent accessibility.

Program is to executive correctly, if both accessibilities left unmentioned or one of the accessibility was mentioned "public". Problem is highlighted

Please explain the reason for differences.

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;
}
}

Answers (18)