本文整理汇总了C#中System.IO.StringReader.Read方法的典型用法代码示例。如果您正苦于以下问题:C# System.IO.StringReader.Read方法的具体用法?C# System.IO.StringReader.Read怎么用?C# System.IO.StringReader.Read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.StringReader
的用法示例。
在下文中一共展示了System.IO.StringReader.Read方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetTokens
public static IEnumerable<Token> GetTokens(string cssFilter)
{
var reader = new System.IO.StringReader(cssFilter);
while (true)
{
int v = reader.Read();
if (v < 0)
yield break;
char c = (char)v;
if (c == '>')
{
yield return new Token(">");
continue;
}
if (c == ' ' || c == '\t')
continue;
string word = c + ReadWord(reader);
yield return new Token(word);
}
}
示例2: Load
public void Load(System.IO.StreamReader file)
{
for (int i = 0; i < BgTileMap.worldSize; i++)
{
System.IO.StringReader stringReader = new System.IO.StringReader(file.ReadLine());
for (int j = 0; j < BgTileMap.worldSize; j++)
{
BgTileMap.bgtiles[i, j].texID = stringReader.Read() - (int)'0';
BgTileMap.bgtiles[i, j].UpdatePassability();
}
}
}
示例3: ReadIn
public void ReadIn()
{
System.IO.StreamReader fileReader = new System.IO.StreamReader("level.txt");
if (fileReader.ReadLine() != "64")
{
Console.Out.WriteLine("FAILURE");
return;
}
for (int i = 0; i < TileMap.worldSize; i++)
{
System.IO.StringReader stringReader = new System.IO.StringReader(fileReader.ReadLine());
for (int j = 0; j < TileMap.worldSize; j++)
{
TileMap.tiles[i, j].texID = stringReader.Read() - (int)'0';
TileMap.tiles[i, j].UpdatePassability();
}
}
fileReader.Close();
}
示例4: LoadFromString
public void LoadFromString(string s)
{
System.IO.StringReader str = new System.IO.StringReader(s);
List<byte> byteList = new List<byte>();
while (str.Peek() >= 0)
byteList.Add((byte)str.Read());
LoadFromByteList(byteList);
}
示例5: HexStringToByteArray
// for the record, I feel that this MachineKey class should be public. Why not have us
// think about security only a little bit, and say, "Here... here's some nice helper
// methods for you to encrypt data only in a tamper-proof way"
// anyways, whatever.
/// <summary>
/// Converts a hex string into a byte array. Original credit to: http://stackoverflow.com/a/311179/323456
/// </summary>
/// <param name="str">string to convert</param>
/// <returns>byte array</returns>
public static byte[] HexStringToByteArray(string hex)
{
int NumberChars = hex.Length / 2;
byte[] bytes = new byte[NumberChars];
using (var sr = new System.IO.StringReader(hex))
{
for (int i = 0; i < NumberChars; i++)
bytes[i] =
Convert.ToByte(new string(new char[2] { (char)sr.Read(), (char)sr.Read() }), 16);
}
return bytes;
}