anon
anon

Reputation:

C# - Add multiple elements to an IList in one line

I am able to do this in one line using Java.

Java:

List<WebElement> colElements;
WebElement rowElement;

//some code

colElements.addAll(rowElement.findElements(By.tagName("td")));

C#:

IList<IWebElement> colElements;
IWebElement rowElement;

//some code

colElements.addAll(rowElement.FindElements(By.TagName("td")));

Clearly, there isn't a method called addAll in the IList interface in C#.

I'm hoping there is another way to do this in one line.

Thanks all!

Upvotes: 0

Views: 688

Answers (1)

Christos
Christos

Reputation: 53958

That you want is the AddRange method.

colElements.AddRange(rowElement.FindElements(By.TagName("td")));

For further documentation about this method, please have a look here.

Upvotes: 4

Related Questions