简体   繁体   English

什么是C#中用于Java中标记和重置方法的等效方法

[英]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. 我正在尝试转换扩展BufferedInputStream类的Java类。 It uses mark(1024) which I think it means the cursor will move to position 1024 and last it invokes reset() method. 它使用mark(1024),我认为这意味着光标将移动到位置1024,最后它调用reset()方法。 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. 现在,我将类更改为从System.IO命名空间中的BufferedStream继承,但是我不知道.net中是否有等效的mark(int)和reset()方法。

There are no equivalent methods in .NET. .NET中没有等效的方法。 mark marks the current position as the position reset should jump to. mark将当前位置reset为位置reset

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;
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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