简体   繁体   中英

what is equivalent methods in C# for mark and reset methods in java

I am trying to convert a java class which extends BufferedInputStream class. It uses mark(1024) which I think it means the cursor will move to position 1024 and last it invokes reset() method. Now I have changed the class to inherit from BufferedStream in System.IO namespace, but I don't know whether there are equivalent methods for mark(int) and reset() methods in .net.

There are no equivalent methods in .NET. mark marks the current position as the position reset should jump to.

But you can implement simplified versions of them yourself:

public class YourClass
{
    private int _resetPosition;

    public void Mark()
    {
        _resetPosition = Position;
    }

    public void Reset()
    {
        Position = _resetPosition;
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM