C# 中的 CharEnumerator.Dispose() 方法
C# 中的 CharEnumerator.Dispose() 方法用於釋放 CharEnumerator 類的當前例項所使用的所有資源。
語法
public void Dispose ();
讓我們看一個實現 CharEnumerator.Dispose() 方法的示例 -
示例
using System;
public class Demo {
public static void Main(){
string strNum = "356";
CharEnumerator ch = strNum.GetEnumerator();
while (ch.MoveNext())
Console.Write(ch.Current + " ");
// disposed
ch.Dispose();
// this will show an error since we disposed the object above
// Console.WriteLine(ch.Current);
}
}輸出
這將產生以下輸出 -
3 5 6
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP