C # programming compilation Error List

Source: Internet
Author: User

This is a foreigner'sArticleThe above details the causes and solutions for many compilation errors. Http://www.vijaymukhi.com/documents/books/csadv/chap10.htm
When many of us know a language at a level of 3/4ProgramYou may encounter many problems, most of which are self-understanding problems.

I met one today with the following error message:
Error 1 inconsistent accessibility: parameter type 'depthmoonsoft. io. tipsconfig. element 'is less accessible than method' minitips _ d1.mainform. setcontrolstyle (system. windows. forms. control, depthmoonsoft. io. tipsconfig. element) 'd: \ plan \ minitips_d1 \ minitips_d1 \ mainform. CS 60 21 minitips_d1
I thought for a long time, why? Below is myCodeFragment:

One file
Namespace Depthmoonsoft. Io
{
Class Tipsconfig
{
Public   Enum Styleelement
{
Font, color, image, transparent, bold, size, width, height, X, Y
} ;

Public   Enum Element
{
Form, miniform, time, text,
Pgupbutton, pgdnbutton, closebutton, newbutton, delbutton, savebutton,
Weekstyle, daystyle
} ;
}
}

Another File
Using Depthmoonsoft. IO;
Namespace Minitips_d1
{
Public Partial Class Mainform: Form
{
Public VoidSetcontrolstyle (control Ctrl, tipsconfig. element name)
{.}
}
}

what causes the compilation error? In fact, it is very simple. First, if the class in the namespace does not have any control operator by default, the default value is internal (tipsconfig is like this). When this type is not declared as a class in another namespace, if the method of this parameter is public and the class is also public, the problem arises (for example, the mainform class can be referenced by classes in other namespaces, but the tipsconfig class is internal, in this case, the setcontrolstyle access permission is restricted by the tipsconfig class. So, the above compilation error will occur ).
solution 2: Improve the access permission of the tipsconfig class, that is, what is public; or remove the public flag of mainform. Very good!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.