-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Issue #5570 Add doc for C# String.Split() #5581
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @mushahidq, thank you for contributing to Codecademy Docs, the entry is well written! 😄
I've requested some changes, could you please review and modify those at your earliest convenience? Thank you! 😃
// Splits a string using a character as a delimeter | ||
string[] subs = String.Split(char) | ||
|
||
// Splits a string using a string as a delimeter | ||
string[] subs = String.Split(string) | ||
|
||
// Splits a string using a character as a delimeter into maximum substrings of the number specified in the second argument. | ||
string[] subs = String.Split(char, Int) | ||
|
||
// Splits a string using a character as a delimeter into maximum substrings of the number specified in the second argument. | ||
string[] subs = String.Split(string, Int) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we separate these as follows:
Using a single character as a delimiter:
string[] subs = String.Split(char)
Using a string as a delimiter:
string[] subs = String.Split(string)
and others...
`.Split()` is a method of class `String`. This method can take upto 3 parameters: | ||
1. The first parameter is the delimeter and it can be a `Char`, an array of characters `Char[]`, or a `String` | ||
2. The second parameter is optional and could be the manximum number of desired substrings which is specified as an integer of type `Int32` | ||
3. The third parameter which is also optional could contain the split options `StringSplitOptions` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameters should be described in the following format:
char
:string
:
and other parameters
@@ -0,0 +1,116 @@ | |||
--- | |||
Title: '.Split()' | |||
Description: 'Used to break string into substrings by specifying a delimeter.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description: 'Used to break string into substrings by specifying a delimeter.' | |
Description: 'Divides a string into an array of substrings based on specified delimiters.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description should begin with a verb
- 'paths/computer-science' | ||
--- | ||
|
||
The `.Split()`** method breaks a string into substrings based on a delimeter which can be a character or another string and returns an array of strings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The `.Split()`** method breaks a string into substrings based on a delimeter which can be a character or another string and returns an array of strings | |
The **`.Split()`** method breaks a string into substrings based on a specified delimiter, which can be a character, an array of characters, or a string. It returns an array of strings containing the split substrings. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reframed for better clarity
Hey @mushahidq are you still working on this? |
Yes, I am. I'll make the requested changes by EOD |
minor fixes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for contributing to Codecademy Docs @mushahidq 😄
The entry looks good for a second round of review! 🚀
Console.WriteLine($"Substring: {sub}"); | ||
} | ||
|
||
// To remove spaces too, we can specify ', ' as the delimeter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// To remove spaces too, we can specify ', ' as the delimeter | |
// To remove spaces, specify ', ' as the delimiter. |
Console.WriteLine($"Substring: {sub}"); | ||
} | ||
|
||
// To limit our substring to 2 we can specify the optional parameter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// To limit our substring to 2 we can specify the optional parameter | |
// To limit the number of substrings to 2, specify the optional parameter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for contributing to Codecademy Docs @mushahidq 😄
The entry looks good for a second round of review! 🚀
Description
Added a new entry for
String.Split()
method in C#Issue Solved
Issue #5570
Type of Change
Checklist
main
branch.Issues Solved
section.