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