TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Dan Raimond
NA
10
539
is this code good? can be better?
Feb 1 2017 4:58 PM
Please check if this piece of code if good or could be better if yes then how and why?
I think its purpose is pretty obvious so I will skip this part. The only thing I can think of is using while instead of for. Anything else can be done better or more efficient way?
public
static
string
GetUniqueName(List<
string
> existedNames,
string
name)
{
name = Regex.Replace(name, @
" \([0-9]+\)$"
,
""
);
if
(existedNames.Any(n => n == name) ==
false
)
return
name;
for
(
int
j = 0; j < 1000; j++)
{
var newName = name +
" ("
+ j +
")"
;
if
(existedNames.Any(n => n == newName) ==
false
)
{
return
newName;
}
}
return
""
;
}
Reply
Answers (
2
)
I want to send sms using TheTexting.com
How to declare the data table column in c#?