StringReader(String) 생성자

정의

지정된 문자열에서 읽어오는 StringReader 클래스의 새 인스턴스를 초기화합니다.

public:
 StringReader(System::String ^ s);
public StringReader (string s);
new System.IO.StringReader : string -> System.IO.StringReader
Public Sub New (s As String)

매개 변수

s
String

StringReader가 초기화되어야 하는 문자열입니다.

예외

s 매개 변수가 null인 경우

예제

이 코드 예제는에 대해 제공 된 큰 예제의 일부는 StringReader 클래스입니다.

// From textReaderText, create a continuous paragraph 
// with two spaces between each sentence.
   String^ aLine;
String^ aParagraph;
StringReader^ strReader = gcnew StringReader( textReaderText );
while ( true )
{
   aLine = strReader->ReadLine();
   if ( aLine != nullptr )
   {
      aParagraph = String::Concat( aParagraph, aLine,  " " );
   }
   else
   {
      aParagraph = String::Concat( aParagraph,  "\n" );
      break;
   }
}

Console::WriteLine(  "Modified text:\n\n{0}", aParagraph );
// From textReaderText, create a continuous paragraph
// with two spaces between each sentence.
string aLine, aParagraph = null;
StringReader strReader = new StringReader(textReaderText);
while(true)
{
    aLine = strReader.ReadLine();
    if(aLine != null)
    {
        aParagraph = aParagraph + aLine + " ";
    }
    else
    {
        aParagraph = aParagraph + "\n";
        break;
    }
}
Console.WriteLine("Modified text:\n\n{0}", aParagraph);
' From textReaderText, create a continuous paragraph 
' with two spaces between each sentence.
Dim aLine, aParagraph As String
Dim strReader As New StringReader(textReaderText)
While True
    aLine = strReader.ReadLine()
    If aLine Is Nothing Then
        aParagraph = aParagraph & vbCrLf
        Exit While
    Else
        aParagraph = aParagraph & aLine & " "
    End If
End While
Console.WriteLine("Modified text:" & vbCrLf & vbCrLf & _ 
    aParagraph)

설명

다음 표에는 다른 일반적인 또는 관련 I/O 작업의 예가 나와 있습니다.

수행할 작업 이 항목의 예제를 참조하세요.
텍스트 파일을 만듭니다. 방법: 파일에 텍스트 쓰기
텍스트 파일에 씁니다. 방법: 파일에 텍스트 쓰기
텍스트 파일에서 읽습니다. 방법: 파일에서 텍스트 읽기
파일에 텍스트를 추가합니다. 방법: 로그 파일 열기 및 추가

File.AppendText

FileInfo.AppendText
파일의 크기를 가져옵니다. FileInfo.Length
파일의 특성을 가져옵니다. File.GetAttributes
파일의 특성을 설정합니다. File.SetAttributes
파일이 있는지 확인합니다. File.Exists
이진 파일에서 읽습니다. 방법: 새로 만든 데이터 파일 읽기 및 쓰기
이진 파일에 씁니다. 방법: 새로 만든 데이터 파일 읽기 및 쓰기

적용 대상

추가 정보