Mass
Explore posts from servers✅ Inconsistent accessibility: property type is less accessible than property.
Hey!
I'm making a UWP app, but from my understanding this is universal to C#.
I have 2 different UWP Pages, that are both a
public sealed partial class
.
In one of them, namely MainPage, I have a list (ObservableCollection to be precise, but I've tried changing to a normal List and it gives the same error)
This is said list: static ObservableCollection<CustomObject> MyList { get; } = new ObservableCollection<CustomObject>();
I want to access this in the second Page, let's just call it Page2. I try to call MainPage.MyList, but can't because of the lists protection level.
So I change the list to be public
, and now I have an inconsistent accessibility.
I'm having a hard time understanding what the error means exactly, can someone clear things up for me? How am I supposed to access the property from Page2?45 replies
How to set a default method for an optional parameter in a method.
I've been trying to google this frantically because I'm sure this question has been asked by others before, but all the results are just for optional parameters in general (and none of the examples are passing methods).
Here's my method example:
All I want is to allow the method to be called without any parameters, in which case condition would just always return true.
Right now I have to call the method like this:
Basically I want the lambda above to be the default value for "condition" in the method. But simply assigning it as the default isn't allowed.
What is the proper syntax for setting a method as a default parameter?
15 replies