Skip to content

Conversation

@indexlang
Copy link

fileNames
.Select(x =>
x.Substring(part1.Length, x.LastIndexOf(part2, StringComparison.Ordinal) - part1.Length))
x.LastIndexOf(part2, StringComparison.Ordinal) > 0 ? x.Substring(part1.Length, x.LastIndexOf(part2, StringComparison.Ordinal) - part1.Length) : "")
Copy link
Member

Choose a reason for hiding this comment

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

How about

                    .Where(x => x.EndsWith(part2, StringComparison.Ordinal))

Copy link
Author

Choose a reason for hiding this comment

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

It's Ok,but why add new line?

Copy link
Member

Choose a reason for hiding this comment

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

No need to select and parse unused items ("").

Copy link
Author

Choose a reason for hiding this comment

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

If client upload a file end with ")",also need parse str,so I think both are fine,you decide.

Copy link
Member

Choose a reason for hiding this comment

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

I prefer to keep the .Select() line unchanged and add

                    .Where(x => x.EndsWith(part2, StringComparison.Ordinal))

for minimal impact.

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.

2 participants