473,320 Members | 1,580 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Inconsistent accessibility

AAV


what is wrong with the code i get
'Error 1 Inconsistent accessibility: parameter type
'ConsoleApplication1.Garage.CarDelegate' is less accessible than method
'ConsoleApplication1.Car.process(ConsoleApplicatio n1.Garage.CarDelegate)
' E:\VS2005_Study\Delegates.cs 49 23 ConsoleApplication1
'

using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace ConsoleApplication1
{
public class Car
{

private String CName;
public bool rotateTires, washCar;
private int speed;
public String name {
get{return CName;}
set{CName=name;}
}
public Car(String name, int s,bool Tire, bool Wash)
{
CName = name;
rotateTires = Tire;
washCar = Wash;
speed = s;
}
public void accelerate(int delta)
{

if (speed > 100)
return;
speed += delta;
if (speed <= 80)
{
Garage.caution(CName + " Going");
}
else if (speed > 80 && speed < 100)
{
Garage.caution("hi " + CName + " take Caution");

}
else if (speed > 100)
{
Garage.expiry("Oh man " + CName + " is Dead");
}

}

public void process(Garage.CarDelegate c)
{
c(this);
}

}

class Garage
{
public delegate void cautionDelegate(String msg);
public delegate void expiryDelegate(String msg);
public delegate void CarDelegate(Car c);
public static cautionDelegate caution;
public static expiryDelegate expiry;
public static CarDelegate card;

public static void Main() {
System.Collections.ArrayList a = new
System.Collections.ArrayList();
caution = new Garage.cautionDelegate(cautionfunction);
expiry = new Garage.expiryDelegate(cautionfunction);
a.Add(new Car("0",10, true, true));
a.Add(new Car("1", 20,true, false ));
a.Add(new Car("2", 30,false , true));
a.Add( new Car("3", 40,false , false ));
for (int i = 0; i < 5; i++)
{
foreach (Car c in a)
c.accelerate(20);
}

card = new CarDelegate(new ServiceCenter().rotatetires);
foreach(Car c in a)
c.process(card);
card = new Car.CarDelegate(new ServiceCenter().cleancar);
foreach(Car c in a)
c.process(card);
Console.ReadLine();

}
public static void cautionfunction(String msg)
{
Console.WriteLine(msg);
}

}

class ServiceCenter
{
public void rotatetires(Car c)
{
if (c.rotateTires == true)
{
Console.WriteLine("Roted Car " + c.name);
}
}
public void cleancar(Car c)
{
if (c.washCar == true)
{
Console.WriteLine("Cleaned Car" + c.name);
}
}
}

}
*** Sent via Developersdex http://www.developersdex.com ***
Feb 2 '06 #1
3 37032
> what is wrong with the code i get
'Error 1 Inconsistent accessibility: parameter type
'ConsoleApplication1.Garage.CarDelegate' is less accessible than
method
'ConsoleApplication1.Car.process(ConsoleApplicatio n1.Garage.CarDelegat
e)
' E:\VS2005_Study\Delegates.cs 49 23 ConsoleApplication1
'
Well, the delegate isn't available to code outside your assembly. In your
particular project it might not be a problem but the C# compiler won't let
you do it.

To solve it, make the class Garage public as well.

<snip> class Garage

<snip>

Change this to:

public class Garage

Hope this helps.

--
Lasse Vågsæther Karlsen
http://usinglvkblog.blogspot.com/
mailto:la***@vkarlsen.no
PGP KeyID: 0x2A42A1C2
Feb 2 '06 #2
AAV <te**********@walla.com> wrote:
what is wrong with the code i get
'Error 1 Inconsistent accessibility: parameter type
'ConsoleApplication1.Garage.CarDelegate' is less accessible than method
'ConsoleApplication1.Car.process(ConsoleApplicatio n1.Garage.CarDelegate)
' E:\VS2005_Study\Delegates.cs 49 23 ConsoleApplication1
'


The Garage class is internal, so even though you've marked the
CarDelegate delegate as public, anything outside the assembly still
won't be able to see it, which means they won't be able to understand
the parameter to Car.process.

Make the Garage class public and it should be fine.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Feb 2 '06 #3
AAV


thanks for ur replies. it worked.
*** Sent via Developersdex http://www.developersdex.com ***
Feb 2 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Sunit Joshi | last post by:
I get this message "Inconsistent accessibility: return type 'TimeTracker.TrackerObjects.Project' is less accessible than method 'TimeTracker.TrackerObjects.GetProject(int)'" Here's the code...
5
by: hodari | last post by:
My program compiles correctly in VS 2003 but fails in VS2005 Express Edition - I get a compile error Inconsistent accessibility: return type 'VA.Customer' is less accessible than method...
4
by: waltborders | last post by:
Hi, Because the blind are unable to use a mouse, keyboard navigation is key. A major difficulty is that not all windows forms controls are keyboard 'tab-able' or 'arrow-able' or have "tab...
5
by: Andy Fish | last post by:
Consider the following code fragment public class Wrapper { protected enum E { IN, OUT }; public class C { protected void foo(E e) { } } } I want the class C to be accessible from outside...
0
by: mariano774 | last post by:
Hello, I'm building a POC architecture framework, in which I have my business objects (BOs) made of internal classes and my transfer objects (TOs) made of public classes. what I'd like to do is...
3
by: WillyL | last post by:
I keep getting the following error message: Inconsistent accessibility: return type 'System.Collections.Generic.IEnumerable<Iteraties.Aandeel>' is less accessible than method...
1
by: bachyen | last post by:
I have the following code, but it is error when I build it. Can you help me? Can you tell me more about 'Inconsistent accessibility: return type', 'Inconsistent accessibility: parameter type'. ...
3
by: EvilProject | last post by:
While working on a scripting engine I Encountered the following problem. First I Created an abstract base class EPType that represent a variable type in the script. internal abstract class...
9
by: dylan.miller | last post by:
I'm having trouble understanding the internal access modifier. There are many classes in my assembly that should not be accessible outside of the assembly. I've used the internal access modifier...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.