Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How much space taken when using System.Linq?

Linq functions on List<T> are awesome, however, in this particular file I'm working on there are only 1 line that use it. So I wanted to know how much space this library took upon importing for use? (I'm using the First function.)

If it's taking too much space then it would make sense to create a custom for loop to iterate through instead. But my code is cleaner when using Linq.

For memory usage I think using Linq and using for don't really make that much difference so I want to know disk space usage if I would use it in Unity3D on mobile devices. If anyone can provide a way to determine disk size of any System library it would be very useful!

like image 393
5argon Avatar asked May 05 '14 08:05

5argon


Video Answer


1 Answers

using directive doesn't really import anything into the application. It is merely language construct for using namespaces. What is really important if the assembly is actually included into the build. Look here:

Namespace: System.Linq

Assembly: System.Core (in System.Core.dll)

So what really matters is if this assembly is included. And yes, it is included by default in common assemblies that are installed in the system, so by just using Linq you don't make your file bigger.

Edit: question appeared to be in light of mono and Unity. In theory you can build .net app without using System.Core.dll if you are not using external libraries (and some of .net's). But very likely that other libraries that you have to use depend on it. Now regarding mono, it looks like mono treats System.Core as special assembly and it is not necessary to reference it, it is done automatically apparently:

using System;
using System.Linq;

namespace t1
{
    class MainClass
    {
        public static void Main (string[] args)
        {
            Console.WriteLine (typeof(Enumerable).Assembly.Location);
        }
    }
}

builds just like that dmcs Program.cs. Also if you create empty solution in Xamarin studio it also works and only System.dll is in references.

like image 107
Andrey Avatar answered Sep 21 '22 22:09

Andrey