StringReader(String) Construtor
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Inicializa uma nova instância da StringReader classe que lê a partir da cadeia especificada.
public:
StringReader(System::String ^ s);
public StringReader(string s);
new System.IO.StringReader : string -> System.IO.StringReader
Public Sub New (s As String)
Parâmetros
- s
- String
A cadeia à qual o StringReader deve ser inicializado.
Exceções
O s parâmetro é null.
Exemplos
Este exemplo de código faz parte de um exemplo maior fornecido para a StringReader classe.
// 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)
Observações
A tabela seguinte lista exemplos de outras tarefas típicas ou relacionadas de E/S.
| Para fazer isso... | Veja o exemplo neste tópico... |
|---|---|
| Crie um arquivo de texto. | Como: Gravar texto em um arquivo |
| Escreve num ficheiro de texto. | Como: Gravar texto em um arquivo |
| Lido de um ficheiro de texto. | Como: Ler texto de um arquivo |
| Adicione texto a um ficheiro. |
Como: Abrir e anexar a um arquivo de log File.AppendText FileInfo.AppendText |
| Obtém o tamanho de um ficheiro. | FileInfo.Length |
| Obtenha as características de um ficheiro. | File.GetAttributes |
| Defina os atributos de um ficheiro. | File.SetAttributes |
| Determina se existe um ficheiro. | File.Exists |
| Lê a partir de um ficheiro binário. | Como: Ler e gravar em um arquivo de dados recém-criado |
| Escreve num ficheiro binário. | Como: Ler e gravar em um arquivo de dados recém-criado |