C
C#2y ago
xyrile

Design pattern

So i was stuck in composite coding with c# I just cant get the ouput maybe someone know about this
namespace Coding.Exercise
{
public interface IValueContainer
{

}

public class SingleValue : IValueContainer
{
public int Value;
}

public class ManyValues : List<int>, IValueContainer
{

}

public static class ExtensionMethods
{
public static int Sum(this List<IValueContainer> containers)
{
int result = 0;
foreach (var c in containers)
foreach (var i in c)
result += i;
return result;
}
}
}
namespace Coding.Exercise
{
public interface IValueContainer
{

}

public class SingleValue : IValueContainer
{
public int Value;
}

public class ManyValues : List<int>, IValueContainer
{

}

public static class ExtensionMethods
{
public static int Sum(this List<IValueContainer> containers)
{
int result = 0;
foreach (var c in containers)
foreach (var i in c)
result += i;
return result;
}
}
}
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server