@BitFlipper:

, BitFlipper wrote

Or maybe a bit cleaner way to do it...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
public class Operation
{
    public <int RunCount, TimeSpan MaxTime, TimeSpan MinTime, TimeSpan AvgTime> Statistics
    {
        get
        {
            lock (m_lock)
            {
                var retVal = new return();
                retVal.RunCount = m_runs;
                ///etc...
 
                return retVal;
            }
        }
    }
}

The "new return()" statement means to instantiate whatever the return type of the current method is. The compiler should be able to infer this from the current method's return type just like it can infer a type when assigning to var from the return of a method. Also there is no Tuple type, just an anonymous type as the return type.

I'm no LINQ expert but isn't this very similar to how LINQ does its magic?

the syntax you are proposing is very similar to GoLang multiple return values:

func (file *File) Write(b []byte) (n int, err Error)