C # 2.0 Learning - Collection

xiaoxiao2021-04-08  432

Compilation and execution:

CSC tokens.cs

tokens // tokens.csusing System; // The System.Collections namespace is made available: using System.Collections; // Declare the Tokens class: public class Tokens: IEnumerable {private string [] elements; Tokens (string source, char [ ] delimiters) {// Parse the string into tokens: elements = source.Split (delimiters);} // IEnumerable Interface Implementation: // Declaration of the GetEnumerator () method // required by IEnumerable public IEnumerator GetEnumerator () {return new TokenEnumerator (this);} // Inner class implements IEnumerator interface: private class TokenEnumerator: IEnumerator {private int position = -1; private Tokens t; public TokenEnumerator (Tokens t) {this.t = t;} // Declare the MoveNext Method Required by ienumerator: public bool movenext () {ix (position

Tokens.cs:

转载请注明原文地址:https://www.9cbs.com/read-132867.html

New Post(0)