-
I'm having following situation where I'm not sure if it's possible: using System;
namespace ConsoleApp3
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
public interface IArray3D
{
int SizeX { get; }
int SizeY { get; }
int SizeZ { get; }
public abstract int[] GetData();
}
public interface IVolume : IArray3D
{
int[] GetSlice(int index);
public new int[] GetData()
{
int[] result = new int [SizeX*SizeY*SizeZ];
for (int i = 0; i < SizeZ; i++)
{
GetSlice(i).AsSpan().CopyTo(result.AsSpan().Slice(i * SizeX * SizeY, SizeX * SizeY));
}
return result;
}
}
public class Volume1 : IVolume
{
public int SizeX => throw new NotImplementedException();
public int SizeY => throw new NotImplementedException();
public int SizeZ => throw new NotImplementedException();
public int[] GetData()
{
throw new NotImplementedException();
}
public int[] GetSlice(int index)
{
throw new NotImplementedException();
}
}
} The explanation is pretty simple: I have a lot of classes the implement the interface So far so good, the So my question is if this is possible at all? Of course the option would be to create a helper method for each individual |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
I think you can do it with explicit interface implementation, but your code contains numerous compilation errors that its hard to try and reason with it into something that actually achieves your aims. Can you please remove all compiler errors from your sample code except for the one indicating your problem? |
Beta Was this translation helpful? Give feedback.
I think you can do it with explicit interface implementation, but your code contains numerous compilation errors that its hard to try and reason with it into something that actually achieves your aims.
Can you please remove all compiler errors from your sample code except for the one indicating your problem?