K
KH
Hi, I can't seem to find the right syntax to do this (if it's even
possible), so if you know and would share I'd appreciate it!
With an interface like ISerializable I like to do an explicit implementation
because its one method, GetObjectData(), isn't meaningful for anything but
serialization, so I just don't want to see it in intellisense unless the
object is being treated as an ISerializable.
Anyways I ran into the situation (shown in code below) where I am inheriting
from an abstract class which implements ISerializable, but I can't call
base.GetObjectData() from an inheritor because I can't treat base as an
ISerializable.
If I don't do an explicit implementation in the base class then everything
works of course, but I'd like to do the explicit implementation if possible,
not to mention just being curious what the syntax is if it exists.
I've included my syntax guesses and the errors they produce. THanks in
advance for any info!
- KH
using global::System;
using global::System.Runtime.Serialization;
[Serializable]
public abstract class A : ISerializable
{
// virtual // The modifier 'virtual' is not valid for this item
void ISerializable.GetObjectData(SerializationInfo info,
StreamingContext ctx)
{
}
};
[Serializable]
public class C : A, ISerializable
{
void ISerializable.GetObjectData(SerializationInfo info,
StreamingContext ctx)
{
// base.GetObjectData(info, ctx); // 'A' does not contain a
definition for 'GetObjectData'
// (base as ISerializable).GetObjectData(info, ctx); // Use of
keyword 'base' is not valid in this context
}
};
possible), so if you know and would share I'd appreciate it!
With an interface like ISerializable I like to do an explicit implementation
because its one method, GetObjectData(), isn't meaningful for anything but
serialization, so I just don't want to see it in intellisense unless the
object is being treated as an ISerializable.
Anyways I ran into the situation (shown in code below) where I am inheriting
from an abstract class which implements ISerializable, but I can't call
base.GetObjectData() from an inheritor because I can't treat base as an
ISerializable.
If I don't do an explicit implementation in the base class then everything
works of course, but I'd like to do the explicit implementation if possible,
not to mention just being curious what the syntax is if it exists.
I've included my syntax guesses and the errors they produce. THanks in
advance for any info!
- KH
using global::System;
using global::System.Runtime.Serialization;
[Serializable]
public abstract class A : ISerializable
{
// virtual // The modifier 'virtual' is not valid for this item
void ISerializable.GetObjectData(SerializationInfo info,
StreamingContext ctx)
{
}
};
[Serializable]
public class C : A, ISerializable
{
void ISerializable.GetObjectData(SerializationInfo info,
StreamingContext ctx)
{
// base.GetObjectData(info, ctx); // 'A' does not contain a
definition for 'GetObjectData'
// (base as ISerializable).GetObjectData(info, ctx); // Use of
keyword 'base' is not valid in this context
}
};