C # access permission issues caused by Attributes. English is very important!

Source: Internet
Author: User

Today, I encountered a problem because the cat did not notice the access permission at the beginning.

Cats and cats use English version. vs. The English version of cats is not good. At the beginning, I still felt that the error message was not clear.

The error was found only after several failed attempts.

 

In this case, I directly added an object to the presentation layer to facilitate data transmission. I directly added a CS file and then wrote the object.

The problem arises.

The class in the CS file added by vs is internal by default.

Generally, the cat and the cat remember to change it to public. But today, because it is called at the same layer, I forgot to change it to public.

I wrote it as an attribute on a form and created this form in the form and passed the value to this property.

If the type of the attribute does not match the data transfer type, an error will be prompted. The error is not prompted because the attribute is matched, but an error is prompted at the place where the attribute is defined.

I didn't understand it at the beginning, so I couldn't figure it out. The attribute type is correct. How can I prompt an error?

The prompt is:

Error 1
Inconsistent accessibility: property type 'System. Collections. Generic. List <qzwbookstore. orderbook> 'is less accessible than property' qzwbookstore. commitorder. orderbooks'
E:/Course Design/qzw-Hf-bookstoretest/qzwbookstore/commitorder. CS
17 32
Qzwbookstore

At that time, I thought I could access accessible ??

The defined code is

Public list <orderbook> orderbooks {Get; set ;}

I have no idea whether public is accessible. Why ??

I have taken a closer look.

Then go to orderbook. CS

After half a day

In front of the mijia public ....

Because the access permission of this attribute is higher than the access permission defined by it!

I have encountered many access permissions before.

However, this seems to work, and it seems to be a very easy place to neglect.

I felt like I was hit by me in a strange and strange way.

 

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.