Skip to content

Change Items.Add to Items.Append #1703

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Change Items.Add to Items.Append #1703

wants to merge 1 commit into from

Conversation

nxtn
Copy link
Contributor

@nxtn nxtn commented May 28, 2019

@garycentric
Copy link
Contributor

@jwmsft: The PR passed the acceptance checklist. Please evaluate further and approve/complete the PR if appropriate. Thanks!

listView1.Items.Add("Item 3");
listView1.Items.Add("Item 4");
listView1.Items.Add("Item 5");
listView1.Items.Append("Item 1");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add is correct.

Append is an extension method from the System.Linq.Enumerable class. It returns a new enumerable with the item appended to the current enumeration, but it doesn't modify the original list (doesn't modify listView1.Items). The purpose of this example is to call ICollection.Add.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ItemCollection.Append

ItemCollection doesn't implement any interface.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the WinRT level, ItemCollection implements IVector, which does have an Append method. But in the projection to C#, IVector projects as IList, which has an Add method instead (from ICollection). So the members of ItemCollection depend on what language you're using.

I think the issue here is that the ItemCollection pages aren't correct.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I was using C++ so I saw the Append method instead of Add.

@nxtn nxtn closed this May 28, 2019
@MikeHillberg
Copy link
Contributor

I opened a separate issue on ItemCollection class page to update/explain the different language projections.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants