Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public abstract class BaseFoo
- {
- public BaseFoo()
- {
- FooMethod();
- }
- public abstract void FooMethod();
- }
- public class Foo : BaseFoo
- {
- private Stream _stream;
- public Foo(Stream stream)
- {
- _stream = stream;
- }
- public override void FooMethod()
- {
- //do anything with the stream
- _stream.Read(...);
- //--> _stream = null
- }
- }
- public Foo(Stream stream)
- {
- _stream = stream;
- base();
- }
- public abstract class BaseFoo
- {
- public BaseFoo(bool testToDoSomething)
- {
- FooMethod();
- }
- public abstract void FooMethod();
- }
- public abstract class BaseFoo
- {
- private Action toRunOnConstruct;
- public BaseFoo(Action toRunOnConstruct)
- {
- this.toRunOnConstruct = toRunOnConstruct;
- toRunOnConstruct.Invoke();
- }
- }
- public class Foo : BaseFoo
- {
- private Stream _stream;
- public Foo(Stream stream) : base(()=> SomethingToDoWithTheStream(stream))
- {
- _stream = stream;
- }
- public static void SomethingToDoWithTheStream(Stream stream)
- {
- //do anything with the stream
- stream.Read(...);
- //--> _stream = null
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement