Skip to main content
Active reading. [<http://english.stackexchange.com/questions/4645/is-it-ever-correct-to-have-a-space-before-a-question-or-exclamation-mark#comment206109_4645>]
Source Link
Peter Mortensen
  • 31.4k
  • 22
  • 110
  • 134

I used a mix of answers like this:

public static Stream ToStream(this string str, Encoding enc = null) { enc = enc ?? Encoding.UTF8; return new MemoryStream(enc.GetBytes(str ?? "")); } 

andAnd then iI use it like this  :

String someStr="This is a Test"; Encoding enc = getEncodingFromSomeWhere(); using (Stream stream = someStr.ToStream(enc)) { //do Do something with the stream.... } 

I used mix of answers like this:

public static Stream ToStream(this string str, Encoding enc = null) { enc = enc ?? Encoding.UTF8; return new MemoryStream(enc.GetBytes(str ?? "")); } 

and then i use it like this  :

String someStr="This is a Test"; Encoding enc = getEncodingFromSomeWhere(); using (Stream stream = someStr.ToStream(enc)) { //do something with stream.... } 

I used a mix of answers like this:

public static Stream ToStream(this string str, Encoding enc = null) { enc = enc ?? Encoding.UTF8; return new MemoryStream(enc.GetBytes(str ?? "")); } 

And then I use it like this:

String someStr="This is a Test"; Encoding enc = getEncodingFromSomeWhere(); using (Stream stream = someStr.ToStream(enc)) { // Do something with the stream.... } 
deleted 15 characters in body
Source Link
Thomas Ayoub
  • 29.6k
  • 16
  • 98
  • 149

great answers iI used mix of answers like this  :

public static Stream ToStream(this string str, Encoding enc = null) { enc = enc ?? Encoding.UTF8; return new MemoryStream(enc.GetBytes(str ?? "")); } 

and then i use it like this :

String someStr="This is a Test"; Encoding enc = getEncodingFromSomeWhere(); using (Stream stream = someStr.ToStream(enc)) { //do something with stream.... } 

great answers i used mix of answers like this  :

public static Stream ToStream(this string str, Encoding enc = null) { enc = enc ?? Encoding.UTF8; return new MemoryStream(enc.GetBytes(str ?? "")); } 

and then i use it like this :

String someStr="This is a Test"; Encoding enc = getEncodingFromSomeWhere(); using (Stream stream = someStr.ToStream(enc)) { //do something with stream.... } 

I used mix of answers like this:

public static Stream ToStream(this string str, Encoding enc = null) { enc = enc ?? Encoding.UTF8; return new MemoryStream(enc.GetBytes(str ?? "")); } 

and then i use it like this :

String someStr="This is a Test"; Encoding enc = getEncodingFromSomeWhere(); using (Stream stream = someStr.ToStream(enc)) { //do something with stream.... } 
Source Link
Robocide
  • 6.8k
  • 5
  • 41
  • 43

great answers i used mix of answers like this :

public static Stream ToStream(this string str, Encoding enc = null) { enc = enc ?? Encoding.UTF8; return new MemoryStream(enc.GetBytes(str ?? "")); } 

and then i use it like this :

String someStr="This is a Test"; Encoding enc = getEncodingFromSomeWhere(); using (Stream stream = someStr.ToStream(enc)) { //do something with stream.... }