indexer

Dynamic linq: Is there a way to access object data by index?

戏子无情 提交于 2019-12-30 10:29:11
问题 I need some in-memory filtering with Dynamic Linq. My objects have only a indexer: public object this[int index] { } The access to my data is like: object[0], object[1],... So my query is like this: // get FilterText from user at runtime // eg. filterText can be: [0] > 100 and [1] = "wpf" collection.AsQueryable().where(filterText); Is there any way to do this? 回答1: I have some news for you. It is actually possible... BUT! (Yes, there´s a but). I assume you are using the dynamic Linq library.

How can you bind an Indexed property to a control in WPF

对着背影说爱祢 提交于 2019-12-28 13:04:14
问题 Given an instance of the class ThisClassShouldBeTheDataContext as the Datacontext for the view class ThisClassShouldBeTheDataContext { public Contacts Contacts {get;set;} } class Contacts { public IEnumerable<Person> Persons {get;set;} public Person this[string Name] { get { var p = from i in Persons where i.Name = Name select i; return p.First(); } } } class Person { public string Name {get;set;} public string PhoneNumber {get;set;} } How can I bind Contact["John"].PhoneNumber to a textbox?

How can you bind an Indexed property to a control in WPF

佐手、 提交于 2019-12-28 13:03:06
问题 Given an instance of the class ThisClassShouldBeTheDataContext as the Datacontext for the view class ThisClassShouldBeTheDataContext { public Contacts Contacts {get;set;} } class Contacts { public IEnumerable<Person> Persons {get;set;} public Person this[string Name] { get { var p = from i in Persons where i.Name = Name select i; return p.First(); } } } class Person { public string Name {get;set;} public string PhoneNumber {get;set;} } How can I bind Contact["John"].PhoneNumber to a textbox?

C# Indexers with Ref Return Gets that also Support Sets

戏子无情 提交于 2019-12-23 12:45:03
问题 Am I doing something wrong here, or as of C# 7.2 Indexers that return by ref and allow set are not supported? Works: public ref byte this[int index] { get { return ref bytes[index]; } } Works too: public byte this[int index] { get { return bytes[index]; } set { bytes[index] = value; } } Fails: public ref byte this[int index] { get { return ref bytes[index]; } set { //<-- CS8147 Properties which return by reference cannot have set accessors bytes[index] = value; } } Fails too: public ref byte

Can't use string as a hash ref..?

ぐ巨炮叔叔 提交于 2019-12-22 10:54:27
问题 I'm trying to parse an HTML document for a web indexing program. To do this I'm using HTML::TokeParser. I'm getting an error on the last line of my first if statement: if ( $token->[1] eq 'a' ) { #href attribute of tag A my $suffix = $token->[2]{href}; that says Can't use string ("<./a>") as a HASH ref while "strict refs" in use at ./indexer.pl line 270, <PAGE_DIR> line 1. Is my problem that (the suffix? or <./a> ?) is a string and needs to be turned into a hash ref? I looked at other posts

Indexer as part of the interface in C#

大憨熊 提交于 2019-12-22 05:06:30
问题 In C#, what's the syntax for declaring an indexer as part of an interface? Is it still this[ ] ? Something feels odd about using the this keyword in an interface. 回答1: public interface IYourList<T> { T this[int index] { get; set; } } 回答2: It is - it's pretty odd syntax at other times if you ask me! But it works. You have to declare the get; and/or set; parts of it with no definition, just a semi-colon, exactly like ordinary properties in an interface. 回答3: I know what you mean but, yes, this

.NET 4.0 Indexer with ObservableCollection

丶灬走出姿态 提交于 2019-12-21 06:42:15
问题 What is the .NET C# syntax for an ObservableCollection with an indexer? I would like an ObservableColletion and refer to the items by ordinal position or a string name. I know you the use this to denote an indexer but I don't know how to put that in an ObservableCollection. Thanks Thanks for the 4 answers. I know how create and ObservableCollection and I know how to create an indexer. I don't know how to combine them. I am asking for sample code for an ObservableCollection with an ordinal and

.NET 4.0 Indexer with ObservableCollection

别说谁变了你拦得住时间么 提交于 2019-12-21 06:41:09
问题 What is the .NET C# syntax for an ObservableCollection with an indexer? I would like an ObservableColletion and refer to the items by ordinal position or a string name. I know you the use this to denote an indexer but I don't know how to put that in an ObservableCollection. Thanks Thanks for the 4 answers. I know how create and ObservableCollection and I know how to create an indexer. I don't know how to combine them. I am asking for sample code for an ObservableCollection with an ordinal and

CDT An internal error occurred during: “Setting up indexer”

守給你的承諾、 提交于 2019-12-21 02:47:28
问题 I use Eclipse with CDT to build C++ code. After loading my workspace I get the following message: An internal error occurred during: "Setting up indexer". Here is the log: eclipse.buildId=I20110613-1736 java.version=1.6.0_24 java.vendor=Sun Microsystems Inc. BootLoader constants: OS=linux, ARCH=x86, WS=gtk, NL=en_US Command-line arguments: -os linux -ws gtk -arch x86 !ENTRY org.eclipse.core.jobs 4 2 2012-10-30 16:46:09.940 !MESSAGE An internal error occurred during: "Setting up indexer".

Eclipse 3.7 cannot resolve Types in C++ Editor

岁酱吖の 提交于 2019-12-19 17:38:32
问题 I recently changed from Eclipse 3.6 to Eclipse 3.7 , which I am using for C++ development in Ubuntu 11.04 . With Version 3.6 I had no big troubles, except that I always had some issues with the indexer. Now with Version 3.7 it begins marking unresolved Types as Errors. Since the indexer seems to dislike me even more, my Eclipse apparently doesn't know types like uint16_t or size_t . In contrary to the displayed errors in the code editor, my compiler has no problems with compiling the code and