473,624 Members | 2,577 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Questing: Inconsistent accessibility

2 New Member
I keep getting the following error message:

Inconsistent accessibility: return type 'System.Collect ions.Generic.IE numerable<Itera ties.Aandeel>' is less accessible than method 'Iteraties.Aand eelPortefeuille .GetEnumerator( )'

I have the following code:

Expand|Select|Wrap|Line Numbers
  1.  using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4.  
  5.  
  6. namespace Iteraties
  7. {
  8.     struct Aandeel
  9.     {
  10.         public string Naam;
  11.         public string Beurs;
  12.     }
  13.  
  14.     public class AandeelPortefeuille
  15.     {
  16.         private ArrayList aandelen;
  17.  
  18.         // constructor
  19.         public AandeelPortefeuille()
  20.         {
  21.             // vul de lijst aandelen
  22.             aandelen = new ArrayList();
  23.             Aandeel aandeel1, aandeel2;
  24.             aandeel1.Naam = "Corus";
  25.             aandeel1.Beurs = "Amsterdam";
  26.             aandeel2.Naam = "Microsoft";
  27.             aandeel2.Beurs = "New York";
  28.  
  29.             aandelen.Add(aandeel1);
  30.             aandelen.Add(aandeel2);    
  31.         }
  32.  
  33.         public IEnumerable<Aandeel> GetEnumerator()
  34.         {
  35.             foreach (Aandeel item in aandelen)
  36.             {
  37.                 yield return item;
  38.             }
  39.         }
  40.     }
  41.  
  42.  
  43.  
  44.     class MainClass
  45.     {
  46.         public static void Main(string[] args)
  47.         {
  48.             AandeelPortefeuille portefeuille = new AandeelPortefeuille();
  49.  
  50.             foreach (Aandeel item in portefeuille.GetEnumerator())
  51.             {
  52.                 Console.WriteLine("Naam: " + item.Naam);
  53.             }
  54.             Console.ReadLine();
  55.         }
  56.     }
  57. }
Can anyone help me?
Jul 6 '07 #1
3 4410
r035198x
13,262 MVP
I keep getting the following error message:

Inconsistent accessibility: return type 'System.Collect ions.Generic.IE numerable<Itera ties.Aandeel>' is less accessible than method 'Iteraties.Aand eelPortefeuille .GetEnumerator( )'

I have the following code:

Expand|Select|Wrap|Line Numbers
  1.  using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4.  
  5.  
  6. namespace Iteraties
  7. {
  8.     struct Aandeel
  9.     {
  10.         public string Naam;
  11.         public string Beurs;
  12.     }
  13.  
  14.     public class AandeelPortefeuille
  15.     {
  16.         private ArrayList aandelen;
  17.  
  18.         // constructor
  19.         public AandeelPortefeuille()
  20.         {
  21.             // vul de lijst aandelen
  22.             aandelen = new ArrayList();
  23.             Aandeel aandeel1, aandeel2;
  24.             aandeel1.Naam = "Corus";
  25.             aandeel1.Beurs = "Amsterdam";
  26.             aandeel2.Naam = "Microsoft";
  27.             aandeel2.Beurs = "New York";
  28.  
  29.             aandelen.Add(aandeel1);
  30.             aandelen.Add(aandeel2);    
  31.         }
  32.  
  33.         public IEnumerable<Aandeel> GetEnumerator()
  34.         {
  35.             foreach (Aandeel item in aandelen)
  36.             {
  37.                 yield return item;
  38.             }
  39.         }
  40.     }
  41.  
  42.  
  43.  
  44.     class MainClass
  45.     {
  46.         public static void Main(string[] args)
  47.         {
  48.             AandeelPortefeuille portefeuille = new AandeelPortefeuille();
  49.  
  50.             foreach (Aandeel item in portefeuille.GetEnumerator())
  51.             {
  52.                 Console.WriteLine("Naam: " + item.Naam);
  53.             }
  54.             Console.ReadLine();
  55.         }
  56.     }
  57. }
Can anyone help me?
When posting code remember to put it in code tags (like I've done for you there).
I've also moved this to the more appropriate .NET forum.
Jul 6 '07 #2
TRScheel
638 Recognized Expert Contributor

...

Expand|Select|Wrap|Line Numbers
  1. ...
  2.     struct Aandeel
  3.     {
  4.         public string Naam;
  5.         public string Beurs;
  6.     }
  7. ...
  8.  
Can anyone help me?

Try this instead:

Expand|Select|Wrap|Line Numbers
  1. ...
  2.     public struct Aandeel
  3.     {
  4.         public string Naam;
  5.         public string Beurs;
  6.     }
  7. ...
  8.  
Jul 6 '07 #3
WillyL
2 New Member
Try this instead:

Expand|Select|Wrap|Line Numbers
  1. ...
  2.     public struct Aandeel
  3.     {
  4.         public string Naam;
  5.         public string Beurs;
  6.     }
  7. ...
  8.  
Thanks, it now works!!
Jul 6 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
68018
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 namespace TimeTracker { public class TrackerObjects { private static Project aProject=null;
5
2659
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 'VA.CustomerDB.GetCustomer(string)' Here is a snippet public class CustomerDB {
4
2977
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 order". The application is built and the next step is to create the custom JAWS (Freedom Scientific)screen reader script to read the application. The application uses the accessibility properties for controls provided by C#. JAWS reads properties...
5
27246
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 the wrapper class, but not
3
37064
by: AAV | last post by:
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(ConsoleApplication1.Garage.CarDelegate) ' E:\VS2005_Study\Delegates.cs 49 23 ConsoleApplication1 ' using System;
0
991
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 have a constructor for each TO and use the BO as a parameter, so to build the TO using the BO what I coded is this public class ClientTO { public string name; public ClientTO (ClientBO client) {
1
3227
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'. using System; public class Tinh_khoang_cach_Ham_tu_dinh_nghia { struct DIEM { public Double x;
3
3220
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 EPType { private String m_Name; public String Name { get { return m_Name; } }
9
5154
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 for these classes. I have public classes that use the internal classes, but I get a CS0051 error if I use an internal class as a parameter to a protected function of a public class. For example: internal class InternalClass { }
0
8249
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8179
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8685
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8493
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6112
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4187
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1797
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1493
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.