本文整理汇总了C#中TextReader.Close方法的典型用法代码示例。如果您正苦于以下问题:C# TextReader.Close方法的具体用法?C# TextReader.Close怎么用?C# TextReader.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextReader
的用法示例。
在下文中一共展示了TextReader.Close方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
// Use this for initialization
void Start()
{
credits = new List<string>();
positionRect = new List<Rect>();
// Create reader & open file
try{
tr = new StreamReader(path);
string temp;
int count = 0;
while((temp = tr.ReadLine()) != null)
{
credits.Add(temp);
positionRect.Add(new Rect(Screen.width/4 - Screen.width/8, (float)(Screen.height * 0.07 * count + Screen.height), (float)(Screen.width/2 + Screen.width/4), (float)(Screen.height * 0.5)));
count++;
}
// Close the stream
tr.Close();
}
catch(FileLoadException e) {
Debug.LogException(e);
credits.Add("Error while loading credits file.");
}
}
示例2: LoadRtfText
/// <summary>
/// Carga una cadena de Texto con formato RTF.
/// </summary>
/// <param name="text">Cadena de Texto que contiene el documento.</param>
/// <returns>Se devuelve el valor 0 en caso de no producirse ningún error en la carga del documento.
/// En caso contrario se devuelve el valor -1.</returns>
public int LoadRtfText(string text)
{
//Resultado de la carga
int res = 0;
//Se abre el fichero de entrada
rtf = new StringReader(text);
//Se crea el analizador léxico para RTF
lex = new RtfLex(rtf);
//Se carga el árbol con el contenido del documento RTF
res = parseRtfTree();
//Se cierra el stream
rtf.Close();
//Se devuelve el resultado de la carga
return res;
}
示例3: Awake
void Awake()
{
if (Application.loadedLevelName == "MainMenu" || Application.loadedLevelName == "Options" || Application.loadedLevelName == "PlanetSelector" || Application.loadedLevelName == "ProfileSelector")
{
isMenu = true;
}
entities = new Dictionary<Vector3Int, GameEntity> (new Vector3EqualityComparer ());
sensorSpaces = new Dictionary<Vector3Int, List<BasicSensor>> (new Vector3EqualityComparer ());
images[0] = Resources.Load("Art/Textures/GUI/button_exit") as Texture2D;
images[1] = Resources.Load("Art/Textures/GUI/button_hint") as Texture2D;
images[2] = Resources.Load("Art/Textures/GUI/button_restart") as Texture2D;
skin = Resources.Load("Art/Textures/GUI/ingame_skin") as GUISkin;
foreach (GameObject go in FindObjectsOfType(typeof(GameObject))){
if (go.name == "Camera"){
CameraDecubeLevel c = go.GetComponent<CameraDecubeLevel>();
levelCamera = c;
break;
}
}
hints = new List<string>();
path = "Assets/Resources/Txt/hints.txt";
try{
tr = new StreamReader(path);
string temp;
while((temp = tr.ReadLine()) != null)
{
if(hints.Count == 12){
hints.Add(temp);
}
hints.Add(temp);
}
// Close the stream
tr.Close();
}
catch(FileLoadException e) {
Debug.LogException(e);
}
}