Csharp/C Sharp by API/System.IO/StringReader
Версия от 15:31, 26 мая 2010; (обсуждение)
new StringReader(String value)
using System;
using System.IO;
class MainClass
{
public static void Main()
{
Object someObject = new StringReader("This is a StringReader");
if (IsType(someObject, "System.IO.TextReader"))
{
Console.WriteLine("GetType: someObject is a TextReader");
}
}
public static bool IsType(object obj, string type)
{
Type t = Type.GetType(type, true, true);
return t == obj.GetType() || obj.GetType().IsSubclassOf(t);
}
}
StringReader.Read
using System;
using System.IO;
public class MainClass
{
static void Main(string[] args)
{
String MyString = "Hello World";
char[] MyChar = new char[12];
StringReader MyStringReader = new StringReader(MyString);
MyStringReader.Read(MyChar, 0, 5);
Console.WriteLine(MyChar);
MyStringReader.Close();
}
}