<p>In <a href="https://web.archive.org/web/20141127115939/https://blogs.msmvps.com/kathleen/2008/09/05/in-praise-of-nested-classes/" rel="noreferrer">Kathleen Dollard's 2008 blog post</a>, she presents an interesting reason to use nested classes in .net. However, she also mentions that FxCop doesn't like nested classes. I'm assuming that the people writing FxCop rules aren't stupid, so there must be reasoning behind that position, but I haven't been able to find it.</p>

[{'answer_id': 48879, 'author': 'hazzen', 'author_id': 5066, 'author_profile': 'https://Stackoverflow.com/users/5066', 'pm_score': 8, 'selected': True, 'text': "<p>Use a nested class when the class you are nesting is only useful to the enclosing class. For instance, nested classes allow you to write something like (simplified):</p>\n\n<pre><code>public class SortedMap {\n    private class TreeNode {\n        TreeNode left;\n        TreeNode right;\n    }\n}\n</code></pre>\n\n<p>You can make a complete definition of your class in one place, you don't have to jump through any PIMPL hoops to define how your class works, and the outside world doesn't need to see anything of your implementation.</p>\n\n<p>If the TreeNode class was external, you would either have to make all the fields <code>public</code> or make a bunch of <code>get/set</code> methods to use it. The outside world would have another class polluting their intellisense.</p>\n"}, {'answer_id': 48892, 'author': 'aku', 'author_id': 1196, 'author_profile': 'https://Stackoverflow.com/users/1196', 'pm_score': 2, 'selected': False, 'text': "<p>If I understand Katheleen's article right, she proposes to use nested class to be able to write SomeEntity.Collection instead of EntityCollection&lt;  SomeEntity>. In my opinion it's controversial way to save you some typing. I'm pretty sure that in real world application collections will have some difference in implementations, so you will need to create separate class anyway. I think that using class name to limit other class scope is not a good idea. It pollutes intellisense and strengthen dependencies between classes. Using namespaces is a standard way to control classes scope. However I find that usage of nested classes like in @hazzen comment is acceptable unless you have tons of nested classes which is a sign of bad design.</p>\n"}, {'answer_id': 48902, 'author': 'Chris Dail', 'author_id': 5077, 'author_profile': 'https://Stackoverflow.com/users/5077', 'pm_score': 3, 'selected': False, 'text': '<p>It depends on the usage. I rarely would ever use a Public nested class but use Private nested classes all of the time. A private nested class can be used for a sub-object that is intended to be used only inside the parent. An example of this would be if a HashTable class contains a private Entry object to store data internally only.</p>\n\n<p>If the class is meant to be used by the caller (externally), I generally like making it a separate standalone class.</p>\n'}, {'answer_id': 48907, 'author': 'Esteban Araya', 'author_id': 781, 'author_profile': 'https://Stackoverflow.com/users/781', 'pm_score': 4, 'selected': False, 'text': '<p><a href="http://java.sun.com/docs/books/tutorial/java/javaOO/nested.html" rel="noreferrer">From Sun\'s Java Tutorial:</a></p>\n\n<p>Why Use Nested Classes?\nThere are several compelling reasons for using nested classes, among them:</p>\n\n<ul>\n<li>It is a way of logically grouping classes that are only used in one place.</li>\n<li>It increases encapsulation.</li>\n<li>Nested classes can lead to more readable and maintainable code.</li>\n</ul>\n\n<p>Logical grouping of classes—If a class is useful to only one other class, then it is logical to embed it in that class and keep the two together. Nesting such "helper classes" makes their package more streamlined.</p>\n\n<p><s>Increased encapsulation—Consider two top-level classes, A and B, where B needs access to members of A that would otherwise be declared private. By hiding class B within class A, A\'s members can be declared private and B can access them. In addition, B itself can be hidden from the outside world.</s> &lt;- This doesn\'t apply to C#\'s implementation of nested classes, this only applies to Java.</p>\n\n<p>More readable, maintainable code—Nesting small classes within top-level classes places the code closer to where it is used. </p>\n'}, {'answer_id': 1084589, 'author': 'kay.one', 'author_id': 98970, 'author_profile': 'https://Stackoverflow.com/users/98970', 'pm_score': 3, 'selected': False, 'text': '<p>Fully Lazy and thread-safe singleton pattern</p>\n<pre><code>public sealed class Singleton\n{\n    Singleton()\n    {\n    }\n\n    public static Singleton Instance\n    {\n        get\n        {\n            return Nested.instance;\n        }\n    }\n    \n    class Nested\n    {\n        // Explicit static constructor to tell C# compiler\n        // not to mark type as beforefieldinit\n        static Nested()\n        {\n        }\n\n        internal static readonly Singleton instance = new Singleton();\n    }\n}\n</code></pre>\n<p>source: <a href="https://csharpindepth.com/Articles/Singleton" rel="nofollow noreferrer">https://csharpindepth.com/Articles/Singleton</a></p>\n'}, {'answer_id': 16093091, 'author': 'nawfal', 'author_id': 661933, 'author_profile': 'https://Stackoverflow.com/users/661933', 'pm_score': 1, 'selected': False, 'text': '<p>I often use nested classes to hide implementation detail. <a href="https://stackoverflow.com/a/3300140/661933">An example from Eric Lippert\'s answer here:</a></p>\n\n<pre><code>abstract public class BankAccount\n{\n    private BankAccount() { }\n    // Now no one else can extend BankAccount because a derived class\n    // must be able to call a constructor, but all the constructors are\n    // private!\n    private sealed class ChequingAccount : BankAccount { ... }\n    public static BankAccount MakeChequingAccount() { return new ChequingAccount(); }\n    private sealed class SavingsAccount : BankAccount { ... }\n}\n</code></pre>\n\n<p><strong>This pattern becomes even better with use of generics.</strong> See <a href="https://stackoverflow.com/questions/16082303/generic-base-class-wraps-nested-generic-class-to-reduce-type-argument-specificat">this question</a> for two cool examples. So I end up writing</p>\n\n<pre><code>Equality&lt;Person&gt;.CreateComparer(p =&gt; p.Id);\n</code></pre>\n\n<p>instead of </p>\n\n<pre><code>new EqualityComparer&lt;Person, int&gt;(p =&gt; p.Id);\n</code></pre>\n\n<p>Also I can have a generic list of <code>Equality&lt;Person&gt;</code> but not <code>EqualityComparer&lt;Person, int&gt;</code></p>\n\n<pre><code>var l = new List&lt;Equality&lt;Person&gt;&gt; \n        { \n         Equality&lt;Person&gt;.CreateComparer(p =&gt; p.Id),\n         Equality&lt;Person&gt;.CreateComparer(p =&gt; p.Name) \n        }\n</code></pre>\n\n<p>where as </p>\n\n<pre><code>var l = new List&lt;EqualityComparer&lt;Person, ??&gt;&gt;&gt; \n        { \n         new EqualityComparer&lt;Person, int&gt;&gt;(p =&gt; p.Id),\n         new EqualityComparer&lt;Person, string&gt;&gt;(p =&gt; p.Name) \n        }\n</code></pre>\n\n<p>is not possible. That\'s the benefit of nested class inheriting from parent class.</p>\n\n<p>Another case (of the same nature - hiding implementation) is when you want to make a class\'s members (fields, properties etc) accessible only for a single class:</p>\n\n<pre><code>public class Outer \n{\n   class Inner //private class\n   {\n       public int Field; //public field\n   }\n\n   static inner = new Inner { Field = -1 }; // Field is accessible here, but in no other class\n}\n</code></pre>\n'}, {'answer_id': 18579666, 'author': 'supercat', 'author_id': 363751, 'author_profile': 'https://Stackoverflow.com/users/363751', 'pm_score': 1, 'selected': False, 'text': "<p>Another use not yet mentioned for nested classes is the segregation of generic types.  For example, suppose one wants to have some generic families of static classes that can take methods with various numbers of parameters, along with values for some of those parameters, and generate delegates with fewer parameters.  For example, one wishes to have a static method which can take an <code>Action&lt;string, int, double&gt;</code> and yield a <code>String&lt;string, int&gt;</code> which will call the supplied action passing 3.5 as the <code>double</code>; one may also wish to have a static method which can take an an <code>Action&lt;string, int, double&gt;</code> and yield an <code>Action&lt;string&gt;</code>, passing <code>7</code> as the <code>int</code> and <code>5.3</code> as the <code>double</code>.  Using generic nested classes, one can arrange to have the method invocations be something like:</p>\n\n<pre><code>MakeDelegate&lt;string,int&gt;.WithParams&lt;double&gt;(theDelegate, 3.5);\nMakeDelegate&lt;string&gt;.WithParams&lt;int,double&gt;(theDelegate, 7, 5.3);\n</code></pre>\n\n<p>or, because the latter types in each expression can be inferred even though the former ones can't:</p>\n\n<pre><code>MakeDelegate&lt;string,int&gt;.WithParams(theDelegate, 3.5);\nMakeDelegate&lt;string&gt;.WithParams(theDelegate, 7, 5.3);\n</code></pre>\n\n<p>Using the nested generic types makes it possible to tell which delegates are applicable to which parts of the overall type description.</p>\n"}, {'answer_id': 19701232, 'author': 'diimdeep', 'author_id': 199154, 'author_profile': 'https://Stackoverflow.com/users/199154', 'pm_score': 0, 'selected': False, 'text': '<p>As <a href="https://stackoverflow.com/a/16093091/199154">nawfal</a> mentioned implementation of Abstract Factory pattern, that code can be axtended to achieve <a href="https://developer.apple.com/library/ios/documentation/General/Conceptual/CocoaEncyclopedia/ClassClusters/ClassClusters.html" rel="nofollow noreferrer">Class Clusters pattern</a> which is based on Abstract Factory pattern.</p>\n'}, {'answer_id': 23323649, 'author': 'Rachin Goyal', 'author_id': 2120933, 'author_profile': 'https://Stackoverflow.com/users/2120933', 'pm_score': 1, 'selected': False, 'text': '<p>The nested classes can be used for following needs:</p>\n\n<ol>\n<li>Classification of the data</li>\n<li>When the logic of the main class is complicated and you feel like you require subordinate objects to manage the class</li>\n<li>When you that the state and existence of the class fully depends on the enclosing class</li>\n</ol>\n'}, {'answer_id': 27575449, 'author': 'Eric Dand', 'author_id': 1159805, 'author_profile': 'https://Stackoverflow.com/users/1159805', 'pm_score': 0, 'selected': False, 'text': '<p>I like to nest exceptions that are unique to a single class, ie. ones that are never thrown from any other place.</p>\n\n<p>For example:</p>\n\n<pre><code>public class MyClass\n{\n    void DoStuff()\n    {\n        if (!someArbitraryCondition)\n        {\n            // This is the only class from which OhNoException is thrown\n            throw new OhNoException(\n                "Oh no! Some arbitrary condition was not satisfied!");\n        }\n        // Do other stuff\n    }\n\n    public class OhNoException : Exception\n    {\n        // Constructors calling base()\n    }\n}\n</code></pre>\n\n<p>This helps keep your project files tidy and not full of a hundred stubby little exception classes.</p>\n'}, {'answer_id': 28959647, 'author': 'tm1', 'author_id': 806690, 'author_profile': 'https://Stackoverflow.com/users/806690', 'pm_score': 0, 'selected': False, 'text': '<p>Bear in mind that you\'ll need to test the nested class. If it is private, you won\'t be able to test it in isolation.</p>\n\n<p>You could make it internal, though, <a href="https://stackoverflow.com/q/1211707/806690">in conjunction with the <code>InternalsVisibleTo</code> attribute</a>. However, this would be the same as making a private field internal only for testing purposes, which I consider bad self-documentation.</p>\n\n<p>So, you may want to only implement private nested classes involving low complexity.</p>\n'}, {'answer_id': 29379421, 'author': 'Tyree Jackson', 'author_id': 1072184, 'author_profile': 'https://Stackoverflow.com/users/1072184', 'pm_score': 3, 'selected': False, 'text': '<p>In addition to the other reasons listed above, there is one more reason that I can think of not only to use nested classes, but in fact public nested classes.  For those who work with multiple generic classes that share the same generic type parameters, the ability to declare a generic namespace would be extremely useful.  Unfortunately, .Net (or at least C#) does not support the idea of generic namespaces.  So in order to accomplish the same goal, we can use generic classes to fulfill the same goal.  Take the following example classes related to a logical entity:</p>\n\n<pre><code>public  class       BaseDataObject\n                    &lt;\n                        tDataObject, \n                        tDataObjectList, \n                        tBusiness, \n                        tDataAccess\n                    &gt;\n        where       tDataObject     : BaseDataObject&lt;tDataObject, tDataObjectList, tBusiness, tDataAccess&gt;\n        where       tDataObjectList : BaseDataObjectList&lt;tDataObject, tDataObjectList, tBusiness, tDataAccess&gt;, new()\n        where       tBusiness       : IBaseBusiness&lt;tDataObject, tDataObjectList, tBusiness, tDataAccess&gt;\n        where       tDataAccess     : IBaseDataAccess&lt;tDataObject, tDataObjectList, tBusiness, tDataAccess&gt;\n{\n}\n\npublic  class       BaseDataObjectList\n                    &lt;\n                        tDataObject, \n                        tDataObjectList, \n                        tBusiness, \n                        tDataAccess\n                    &gt;\n:   \n                    CollectionBase&lt;tDataObject&gt;\n        where       tDataObject     : BaseDataObject&lt;tDataObject, tDataObjectList, tBusiness, tDataAccess&gt;\n        where       tDataObjectList : BaseDataObjectList&lt;tDataObject, tDataObjectList, tBusiness, tDataAccess&gt;, new()\n        where       tBusiness       : IBaseBusiness&lt;tDataObject, tDataObjectList, tBusiness, tDataAccess&gt;\n        where       tDataAccess     : IBaseDataAccess&lt;tDataObject, tDataObjectList, tBusiness, tDataAccess&gt;\n{\n}\n\npublic  interface   IBaseBusiness\n                    &lt;\n                        tDataObject, \n                        tDataObjectList, \n                        tBusiness, \n                        tDataAccess\n                    &gt;\n        where       tDataObject     : BaseDataObject&lt;tDataObject, tDataObjectList, tBusiness, tDataAccess&gt;\n        where       tDataObjectList : BaseDataObjectList&lt;tDataObject, tDataObjectList, tBusiness, tDataAccess&gt;, new()\n        where       tBusiness       : IBaseBusiness&lt;tDataObject, tDataObjectList, tBusiness, tDataAccess&gt;\n        where       tDataAccess     : IBaseDataAccess&lt;tDataObject, tDataObjectList, tBusiness, tDataAccess&gt;\n{\n}\n\npublic  interface   IBaseDataAccess\n                    &lt;\n                        tDataObject, \n                        tDataObjectList, \n                        tBusiness, \n                        tDataAccess\n                    &gt;\n        where       tDataObject     : BaseDataObject&lt;tDataObject, tDataObjectList, tBusiness, tDataAccess&gt;\n        where       tDataObjectList : BaseDataObjectList&lt;tDataObject, tDataObjectList, tBusiness, tDataAccess&gt;, new()\n        where       tBusiness       : IBaseBusiness&lt;tDataObject, tDataObjectList, tBusiness, tDataAccess&gt;\n        where       tDataAccess     : IBaseDataAccess&lt;tDataObject, tDataObjectList, tBusiness, tDataAccess&gt;\n{\n}\n</code></pre>\n\n<p>We can simplify the signatures of these classes by using a generic namespace (implemented via nested classes):</p>\n\n<pre><code>public\npartial class   Entity\n                &lt;\n                    tDataObject, \n                    tDataObjectList, \n                    tBusiness, \n                    tDataAccess\n                &gt;\n        where   tDataObject     : Entity&lt;tDataObject, tDataObjectList, tBusiness, tDataAccess&gt;.BaseDataObject\n        where   tDataObjectList : Entity&lt;tDataObject, tDataObjectList, tBusiness, tDataAccess&gt;.BaseDataObjectList, new()\n        where   tBusiness       : Entity&lt;tDataObject, tDataObjectList, tBusiness, tDataAccess&gt;.IBaseBusiness\n        where   tDataAccess     : Entity&lt;tDataObject, tDataObjectList, tBusiness, tDataAccess&gt;.IBaseDataAccess\n{\n\n    public  class       BaseDataObject {}\n\n    public  class       BaseDataObjectList : CollectionBase&lt;tDataObject&gt; {}\n\n    public  interface   IBaseBusiness {}\n\n    public  interface   IBaseDataAccess {}\n\n}\n</code></pre>\n\n<p>Then, through the use of partial classes as suggested by Erik van Brakel in an earlier comment, you can separate the classes into separate nested files.  I recommend using a Visual Studio extension like NestIn to support nesting the partial class files.  This allows the "namespace" class files to also be used to organize the nested class files in a folder like way.</p>\n\n<p>For example:</p>\n\n<p>Entity.cs</p>\n\n<pre><code>public\npartial class   Entity\n                &lt;\n                    tDataObject, \n                    tDataObjectList, \n                    tBusiness, \n                    tDataAccess\n                &gt;\n        where   tDataObject     : Entity&lt;tDataObject, tDataObjectList, tBusiness, tDataAccess&gt;.BaseDataObject\n        where   tDataObjectList : Entity&lt;tDataObject, tDataObjectList, tBusiness, tDataAccess&gt;.BaseDataObjectList, new()\n        where   tBusiness       : Entity&lt;tDataObject, tDataObjectList, tBusiness, tDataAccess&gt;.IBaseBusiness\n        where   tDataAccess     : Entity&lt;tDataObject, tDataObjectList, tBusiness, tDataAccess&gt;.IBaseDataAccess\n{\n}\n</code></pre>\n\n<p>Entity.BaseDataObject.cs</p>\n\n<pre><code>partial class   Entity&lt;tDataObject, tDataObjectList, tBusiness, tDataAccess&gt;\n{\n\n    public  class   BaseDataObject\n    {\n\n        public  DataTimeOffset  CreatedDateTime     { get; set; }\n        public  Guid            CreatedById         { get; set; }\n        public  Guid            Id                  { get; set; }\n        public  DataTimeOffset  LastUpdateDateTime  { get; set; }\n        public  Guid            LastUpdatedById     { get; set; }\n\n        public\n        static\n        implicit    operator    tDataObjectList(DataObject dataObject)\n        {\n            var returnList  = new tDataObjectList();\n            returnList.Add((tDataObject) this);\n            return returnList;\n        }\n\n    }\n\n}\n</code></pre>\n\n<p>Entity.BaseDataObjectList.cs</p>\n\n<pre><code>partial class   Entity&lt;tDataObject, tDataObjectList, tBusiness, tDataAccess&gt;\n{\n\n    public  class   BaseDataObjectList : CollectionBase&lt;tDataObject&gt;\n    {\n\n        public  tDataObjectList ShallowClone() \n        {\n            var returnList  = new tDataObjectList();\n            returnList.AddRange(this);\n            return returnList;\n        }\n\n    }\n\n}\n</code></pre>\n\n<p>Entity.IBaseBusiness.cs</p>\n\n<pre><code>partial class   Entity&lt;tDataObject, tDataObjectList, tBusiness, tDataAccess&gt;\n{\n\n    public  interface   IBaseBusiness\n    {\n        tDataObjectList Load();\n        void            Delete();\n        void            Save(tDataObjectList data);\n    }\n\n}\n</code></pre>\n\n<p>Entity.IBaseDataAccess.cs</p>\n\n<pre><code>partial class   Entity&lt;tDataObject, tDataObjectList, tBusiness, tDataAccess&gt;\n{\n\n    public  interface   IBaseDataAccess\n    {\n        tDataObjectList Load();\n        void            Delete();\n        void            Save(tDataObjectList data);\n    }\n\n}\n</code></pre>\n\n<p>The files in the visual studio solution explorer would then be organized as such:</p>\n\n<pre><code>Entity.cs\n+   Entity.BaseDataObject.cs\n+   Entity.BaseDataObjectList.cs\n+   Entity.IBaseBusiness.cs\n+   Entity.IBaseDataAccess.cs\n</code></pre>\n\n<p>And you would implement the generic namespace like the following:</p>\n\n<p>User.cs</p>\n\n<pre><code>public\npartial class   User\n:\n                Entity\n                &lt;\n                    User.DataObject, \n                    User.DataObjectList, \n                    User.IBusiness, \n                    User.IDataAccess\n                &gt;\n{\n}\n</code></pre>\n\n<p>User.DataObject.cs</p>\n\n<pre><code>partial class   User\n{\n\n    public  class   DataObject : BaseDataObject \n    {\n        public  string  UserName            { get; set; }\n        public  byte[]  PasswordHash        { get; set; }\n        public  bool    AccountIsEnabled    { get; set; }\n    }\n\n}\n</code></pre>\n\n<p>User.DataObjectList.cs</p>\n\n<pre><code>partial class   User\n{\n\n    public  class   DataObjectList : BaseDataObjectList {}\n\n}\n</code></pre>\n\n<p>User.IBusiness.cs</p>\n\n<pre><code>partial class   User\n{\n\n    public  interface   IBusiness : IBaseBusiness {}\n\n}\n</code></pre>\n\n<p>User.IDataAccess.cs</p>\n\n<pre><code>partial class   User\n{\n\n    public  interface   IDataAccess : IBaseDataAccess {}\n\n}\n</code></pre>\n\n<p>And the files would be organized in the solution explorer as follows:</p>\n\n<pre><code>User.cs\n+   User.DataObject.cs\n+   User.DataObjectList.cs\n+   User.IBusiness.cs\n+   User.IDataAccess.cs\n</code></pre>\n\n<p>The above is a simple example of using an outer class as a generic namespace.  I\'ve built "generic namespaces" containing 9 or more type parameters in the past.  Having to keep those type parameters synchronized across the nine types that all needed to know the type parameters was tedious, especially when adding a new parameter.  The use of generic namespaces makes that code far more manageable and readable.</p>\n'}, {'answer_id': 50997412, 'author': 'Alex Martinez', 'author_id': 4698151, 'author_profile': 'https://Stackoverflow.com/users/4698151', 'pm_score': 0, 'selected': False, 'text': '<p>yes for this case:</p>\n\n<pre><code>class Join_Operator\n{\n\n    class Departamento\n    {\n        public int idDepto { get; set; }\n        public string nombreDepto { get; set; }\n    }\n\n    class Empleado\n    {\n        public int idDepto { get; set; }\n        public string nombreEmpleado { get; set; }\n    }\n\n    public void JoinTables()\n    {\n        List&lt;Departamento&gt; departamentos = new List&lt;Departamento&gt;();\n        departamentos.Add(new Departamento { idDepto = 1, nombreDepto = "Arquitectura" });\n        departamentos.Add(new Departamento { idDepto = 2, nombreDepto = "Programación" });\n\n        List&lt;Empleado&gt; empleados = new List&lt;Empleado&gt;();\n        empleados.Add(new Empleado { idDepto = 1, nombreEmpleado = "John Doe." });\n        empleados.Add(new Empleado { idDepto = 2, nombreEmpleado = "Jim Bell" });\n\n        var joinList = (from e in empleados\n                        join d in departamentos on\n                        e.idDepto equals d.idDepto\n                        select new\n                        {\n                            nombreEmpleado = e.nombreEmpleado,\n                            nombreDepto = d.nombreDepto\n                        });\n        foreach (var dato in joinList)\n        {\n            Console.WriteLine("{0} es empleado del departamento de {1}", dato.nombreEmpleado, dato.nombreDepto);\n        }\n    }\n}\n</code></pre>\n'}, {'answer_id': 63224333, 'author': 'Hamid', 'author_id': 9523274, 'author_profile': 'https://Stackoverflow.com/users/9523274', 'pm_score': 0, 'selected': False, 'text': "<p>Base on my understanding of this concept\nwe could use this feature when classes are related to each other conceptually.\nI mean some of them are complete one Item in our business like entities that exist in the DDD world that help to an aggregate root object to complete its business logic.</p>\n<p>In order to clarify I'm going to show this via an example:</p>\n<p>Imagine that we have two classes like Order and OrderItem.\nIn order class, we are going to manage all orderItems  and in OrderItem we are holding data about a single order\nfor clarification, you can see below classes:</p>\n<pre><code> class Order\n    {\n        private List&lt;OrderItem&gt; _orderItems = new List&lt;OrderItem&gt;();\n\n        public void AddOrderItem(OrderItem line)\n        {\n            _orderItems.Add(line);\n        }\n\n        public double OrderTotal()\n        {\n            double total = 0;\n            foreach (OrderItem item in _orderItems)\n            {\n                total += item.TotalPrice();\n            }\n\n            return total;\n        }\n\n        // Nested class\n        public class OrderItem\n        {\n            public int ProductId { get; set; }\n            public int Quantity { get; set; }\n            public double Price { get; set; }\n            public double TotalPrice() =&gt; Price * Quantity;\n        }\n    }\n\n    class Program\n    {\n\n        static void Main(string[] args)\n        {\n            Order order = new Order();\n\n            Order.OrderItem orderItem1 = new Order.OrderItem();\n            orderItem1.ProductId = 1;\n            orderItem1.Quantity = 5;\n            orderItem1.Price = 1.99;\n            order.AddOrderItem(orderItem1);\n\n            Order.OrderItem orderItem2 = new Order.OrderItem();\n            orderItem2.ProductId = 2;\n            orderItem2.Quantity = 12;\n            orderItem2.Price = 0.35;\n            order.AddOrderItem(orderItem2);\n\n            Console.WriteLine(order.OrderTotal());\n            ReadLine();\n        }\n\n\n    }\n</code></pre>\n"}]
['https://Stackoverflow.com/questions/48872', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/100/']