Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static class LibraryClass
- {
- public static void Test<T>(T foo, T bar)
- {
- // vastly simplified... I am aware that it is already in order here ;-p
- var list = new List<Wrapper<T>>();
- list.Add(new Wrapper<T> { Tag = 1, Value = foo });
- list.Add(new Wrapper<T> { Tag = 2, Value = bar });
- list.Sort((x,y) => x.Tag.CompareTo(y.Tag)); // BOOM!!
- }
- }
- public class Wrapper<T> // public to prove this isn't a factor...
- {
- public T Value { get; set; }
- public int Tag { get; set; }
- }
- public static class Program
- {
- static void Main()
- {
- MyData foo = new MyData {Name = "foo"},
- bar = new MyData {Name = "bar"};
- LibraryClass.Test<MyData>(foo, bar);
- }
- }
- class MyData // but make MyData public and it works...
- {
- public string Name { get; set; }
- }
Add Comment
Please, Sign In to add comment