I am implementing fileupload/downloading from SQL Server. Code is working all fine.
I came across this code - can someone please explain what this line is doing?
string[] strPath = strFile.Split(Convert.ToChar(@"\"));
I know it's splitting a string (strFile) ... and I think the delimiter is '\'. But why is a string array string[] strPath declared? And why is (Convert.ToChar()) used ?
Kind regards.
Convert.ToChar(@"\") could be '\\' as well. The first slash is to escape the second. @'\' does not work for chars. And '\' escapes the second quote, not closing the char definition. Convert.ToChar(@"\") is a verbose way of writing whats necessary.
An array of string[] is declared because if you split a string with a delimiter it can return multiple strings, if the delimter was found. Each splitted piece is a seperate string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With