Get collection from object [closed] - c#

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
In C#/.Net is there a way to reflect from an object, which is a member of a collection up to the collection itself so we can (a) iterate over the other members of the collection, and (b) assuming the collection is itself a member of a collection follow the tree back up to the root?
A typical example would be if there is a common attribute which can be set at multiple levels the collection tree and when an object is changed, find the nearest trunk entry.

The only way to do it is if the type you are working with explicitly has things in it to handle this, in winforms this is handled via the IComponent.Site property. Other libraries may use other standards.

Related

C# object serialization safely and best methods? Anyone can give me ans? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
Object serialization method ? I am creating my own arraylist serialization application.
Serialization is a huge topic. Without discussing lots of details about what your requirements are, only vague guidance is possible, in which case: by default, probably keep it simple and use generic things like JSON or XML; Json.NET has over 100 samples which are very reasonable for general-purpose scenarios. If you have specific requirements about size/performance/compatibility/capabilities/etc, then other tools or formats may be more appropriate. The only main rules are:
do not blindly use BinaryFormatter (or NetDataContractSerializer)
don't roll your own home-baked serialization format/code unless you know a lot about serialization and can explain why none of the myriad of pre-existing libraries won't work for your specific scenario

Remove items from ObservableConcurrentCollection [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
I have a DataGrid with ItemsSource bound in XAML to an ObservableConcurrentCollection property.
This allows me to update the collection from a worker thread, and have the changes automatically reflected in my DataGrid.
The problem is that I can only add items to that collection. I need to be able to remove items but I can't find any method that does that.
Does ObservableConcurrentCollection allow removing items? If not, is there an alternative collection I can use?
You should use AsyncObservableCollection which provides feature to update the collection from worker Thread and allows Remove operation. You can read copy the code from https://gist.github.com/thomaslevesque/10023516.

How to fix my C# click method? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I am using a list in class Register:
Judging by the image your property O is a list of type List<Order> but the three items you are adding are of type Shop.
So either O needs to become a List<Shop> or the Order1, Order2, Order3 variables need to be type Order.

WPF Dependency guide [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I’m trying to learn some WPF tricks and I’m stuck on WPF-Dependency.
Can anybody explain what is it and it’s use. Any websites with the explanation of using it.
What is Dependency
Dependency means an object depending upon another object.
An object O1 depends upon another object O2 when O1 is using O2's property to do some changes in its own(O1) property.
Why we need it
To achieve these changes, some notification logic is needed of-course. Before WPF or similar technology, we were doing it using event handlers.
Now, with WPF and similar technologies, we tell the underlying framework to do this for us. We tell underlying framework what we want ( using some syntax ) without bothering how ? And underlying framework does this for us.
Provisions provided by WPF
Binding using code/xaml.
DependencyProperty
Triggers
INotifyPropertyChanged interface
Learn about these, and slowly you will get the hold of it.

Why properties are needed in C#? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
In C#, properties could be used to return or reset the value of private members of a class. But people can also define methods to fulfill these, so my questions are:
why bother to introduce properties, why don't just use methods?
private members are intended to be accessed by the class only. then why are properties defined to modify the private member?
Methods represent actions (think of them as verbs) and properties represent data (think of them as nouns). Properties should not perform computationally complex logic or produce side effects. Methods on the other hand should.
Why use Properties:
Properties are be used in data binding. For example, in ASP.Net MVC you use properties as part of Models.
Properties provide fine-grained access control. For example, you can have read-only properties, by just providing a getter.
It helps with debugging. For example, you can set a breakpoint on the property and the IDE will break when the value of the property is touched.

Categories