when does C # give this compilation error?
'Favorite.Favorites.FavoriteCollection' is unavailable due to protection level
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); } }
This compile-time error means that the property you are trying to access is not public, and the only way to access it is to either change its access modifier or use reflection .
public
, : , , , interal (protected private), , :
interal
protected
private
public class FavoriteCollection { ... }
Source: https://habr.com/ru/post/1762152/More articles:associate user identifiers with ListView elements - androidAre there Java app templates similar to appfuse? - javaPreloader with jQuery OR Advanced page load behavior using jQuery launcher - jqueryMust learn classes for Java! - javaГраница CSS надействует по-разному? - htmlhow to get current time and then compare them using jquery - javascriptMySQL JOIN & Split String - stringAndroid - custom auto kit layoutTextView - androidSupport for multiple display mode menus in Silverlight Prism - silverlightPassword Database for Crossword Puzzles or Web Services - databaseAll Articles