Friday 8 June 2018

c# - When do we need to put using directives inside a namespace scope?




I don't know why Asp.net MVC developers put the using directives inside System.Web.Mvc namespace as follows.



namespace System.Web.Mvc
{
using System;
using System.Collections.ObjectModel;


[Serializable]
public class ModelErrorCollection : Collection
{

public void Add(Exception exception)
{
Add(new ModelError(exception));
}

public void Add(string errorMessage)

{
Add(new ModelError(errorMessage));
}
}
}


When do we need to put using directives inside a namespace scope?


Answer



See Should 'using' statements be inside or outside the namespace?



No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...