本文介绍了C#编译错误:“X无法访问,由于其保护级别”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当c#给出此编译错误?

when c# gives this compile error?



private void Form1_Load(object sender, EventArgs e)
{
    Favorites objFavorites = new Favorites();

    objFavorites.ScanFavorites();
    foreach (WebFavorite objWebFavorite in objFavorites.FavoriteCollection)
    {
        ListViewItem objListViewItem = new ListViewItem();
        objListViewItem.Text = objWebFavorite.Name;
        objListViewItem.SubItems.Add(objWebFavorite.Url);
        lstFavorites.Items.Add(objListViewItem);
    }
}


推荐答案

编译时错误意味着您尝试访问的属性不是 public ,访问它的唯一方法是修改或使用。

This compile-time error means that the property you are trying to access is not public and the only way to access it is by either modifying its access modifier or using reflection.

这篇关于C#编译错误:“X无法访问,由于其保护级别”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-15 13:33
查看更多