Skip to content

complete#9

Open
coopian wants to merge 1 commit into552ODST:masterfrom
coopian:master
Open

complete#9
coopian wants to merge 1 commit into552ODST:masterfrom
coopian:master

Conversation

@coopian
Copy link

@coopian coopian commented Aug 19, 2021

No description provided.

return default;
bool valid = false;

try
Copy link
Member

Choose a reason for hiding this comment

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

Was surprised to see a try-catch! However, a try-parse @ line 24 will work just the same.

{


List<int> list = hyphenNum.Split('-').Select(p => int.Parse(p)).ToList();
Copy link
Member

@yurisim yurisim Aug 30, 2021

Choose a reason for hiding this comment

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

You can instead do

Suggested change
List<int> list = hyphenNum.Split('-').Select(p => int.Parse(p)).ToList();
List<int> list = hyphenNum.Split('-').Select(int.Parse).ToList();

when using single character wheres and selects.

For example, can use someString.Where(char.IsNumber) without having to do the lambda expression


DateTime dt;

if (DateTime.TryParseExact(hyphenNum, format, invariant, DateTimeStyles.None, out dt))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (DateTime.TryParseExact(hyphenNum, format, invariant, DateTimeStyles.None, out dt))
return (DateTime.TryParseExact(hyphenNum, format, invariant, DateTimeStyles.None, out dt))

}
else
{
oneWord = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(aFewWords.Trim().ToLower());
Copy link
Member

Choose a reason for hiding this comment

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

Was expecting a split instead of ToTitleCast

But this also works.


for(int i = 0; i < aWord.Length; i++)
{
if (aWord[i] == 'a' || aWord[i] == 'e'|| aWord[i] == 'i'|| aWord[i] == 'o' || aWord[i] == 'u'||
Copy link
Member

Choose a reason for hiding this comment

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

Use .Contains instead of this OR statement.

Also toLower (or toUpper) the input so that you only need to worry about one case of vowels instead of both.

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