{"action":"created","issue":{"url":"https://api.github.com/repos/JoshClose/CsvHelper/issues/494","repository_url":"https://api.github.com/repos/JoshClose/CsvHelper","labels_url":"https://api.github.com/repos/JoshClose/CsvHelper/issues/494/labels{/name}","comments_url":"https://api.github.com/repos/JoshClose/CsvHelper/issues/494/comments","events_url":"https://api.github.com/repos/JoshClose/CsvHelper/issues/494/events","html_url":"https://github.com/JoshClose/CsvHelper/issues/494","id":140896583,"number":494,"title":"Write to string helper methods","user":{"login":"NN---","id":580536,"avatar_url":"https://avatars.githubusercontent.com/u/580536?v=3","gravatar_id":"","url":"https://api.github.com/users/NN---","html_url":"https://github.com/NN---","followers_url":"https://api.github.com/users/NN---/followers","following_url":"https://api.github.com/users/NN---/following{/other_user}","gists_url":"https://api.github.com/users/NN---/gists{/gist_id}","starred_url":"https://api.github.com/users/NN---/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NN---/subscriptions","organizations_url":"https://api.github.com/users/NN---/orgs","repos_url":"https://api.github.com/users/NN---/repos","events_url":"https://api.github.com/users/NN---/events{/privacy}","received_events_url":"https://api.github.com/users/NN---/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/JoshClose/CsvHelper/labels/question","name":"question","color":"fbca04"}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-03-15T07:28:57Z","updated_at":"2016-10-05T12:09:38Z","closed_at":"2016-10-05T04:09:54Z","body":"There are no simple helper methods to write CSV into simple string.\r\n\r\nI would to have something like:\r\n\r\n```cs\r\nusing System;\r\nusing System.IO'\r\n\r\nclass CsvStringUtils\r\n{\r\n\tpublic static string WriteCsvRecord<T>(T record)\r\n\t{\r\n\t\tif (record == null) throw new ArgumentNullException(\"record\");\r\n\r\n\t\tusing (var s = new StringWriter())\r\n\t\tusing (var w = new CsvWriter(s))\r\n\t\t{\r\n\t\t\tw.WriteRecord(record);\r\n\t\t\t\t\r\n\t\t\treturn RemoveNewLine(s.GetStringBuilder());\r\n\t\t}\r\n\t}\r\n\r\n\tpublic static string WriteCsvHeader(Type type)\r\n\t{\r\n\t\tif (type == null) throw new ArgumentNullException(\"type\");\r\n\r\n\t\tusing (var s = new StringWriter())\r\n\t\tusing (var w = new CsvWriter(s))\r\n\t\t{\r\n\t\t\tw.WriteHeader(type);\r\n\t\t\treturn RemoveNewLine(s.GetStringBuilder());\r\n\t\t}\r\n\t}\r\n\r\n\tpublic static string WriteCsvHeader<T>()\r\n\t{\r\n\t\treturn WriteCsvHeader(typeof(T));\r\n\t}\r\n\r\n\tprivate static string RemoveNewLine(StringBuilder sb)\r\n\t{\r\n\t\tsb.Length -= Environment.NewLine.Length;\r\n\t\treturn sb.ToString();\r\n\t}\r\n}\r\n```\r\n\r\nThanks"},"comment":{"url":"https://api.github.com/repos/JoshClose/CsvHelper/issues/comments/251656476","html_url":"https://github.com/JoshClose/CsvHelper/issues/494#issuecomment-251656476","issue_url":"https://api.github.com/repos/JoshClose/CsvHelper/issues/494","id":251656476,"user":{"login":"NN---","id":580536,"avatar_url":"https://avatars.githubusercontent.com/u/580536?v=3","gravatar_id":"","url":"https://api.github.com/users/NN---","html_url":"https://github.com/NN---","followers_url":"https://api.github.com/users/NN---/followers","following_url":"https://api.github.com/users/NN---/following{/other_user}","gists_url":"https://api.github.com/users/NN---/gists{/gist_id}","starred_url":"https://api.github.com/users/NN---/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NN---/subscriptions","organizations_url":"https://api.github.com/users/NN---/orgs","repos_url":"https://api.github.com/users/NN---/repos","events_url":"https://api.github.com/users/NN---/events{/privacy}","received_events_url":"https://api.github.com/users/NN---/received_events","type":"User","site_admin":false},"created_at":"2016-10-05T12:09:38Z","updated_at":"2016-10-05T12:09:38Z","body":"WriteRecord and WriteHeader add new line character in the end which I don't want to be written."}}
{"actor":{"display_login":"NN---"}}