In C#, you can split a string into two strings using the Split method or by extracting substrings using the substring method. Here are two ways you can achieve this:
Split method:main.cs140 chars5 lines
main.cs159 chars5 lines
In the first method, we use the Split method to split the string into an array of strings based on a specified delimiter (in this case, the space character). Then, we assign the first and second elements of the array to the str1 and str2 strings, respectively.
In the second method, we use the IndexOf method to find the position of the first occurrence of the space character in the string. We then use the Substring method to extract the two substrings from the original string. str1 is the substring from the beginning of the original string up to the space character, and str2 is the substring that starts after the space character.
gistlibby LogSnag