In C#, what is the difference between public, private, protected, and having no access modifier?

All my college years I have been using public, and would like to know the difference between public, private, and protected? Also what does static do as opposed to having nothing? 17 s 17 Access modifiers From docs.microsoft.com: public The type or member can be accessed by any other code in the same assembly or … Read more

ASP.NET Web Site or ASP.NET Web Application?

When I start a new ASP.NET project in Visual Studio, I can create an ASP.NET Web Application or I can create an ASP.NET Web Site. What is the difference between ASP.NET Web Application and ASP.NET Web Site? Why would I choose one over other? Is the answer different based on which version of Visual Studio … Read more

Change the selected value of a drop-down list with jQuery

I have a drop-down list with known values. What I’m trying to do is set the drop down list to a particular value that I know exists using jQuery. Using regular JavaScript, I would do something like: ddl = document.getElementById(“ID of element goes here”); ddl.value = 2; // 2 being the value I want to … Read more

How do you set the Content-Type header for an HttpClient request?

I’m trying to set the Content-Type header of an HttpClient object as required by an API I am calling. I tried setting the Content-Type like below: using (var httpClient = new HttpClient()) { httpClient.BaseAddress = new Uri(“http://example.com/”); httpClient.DefaultRequestHeaders.Add(“Accept”, “application/json”); httpClient.DefaultRequestHeaders.Add(“Content-Type”, “application/json”); // … } It allows me to add the Accept header but when I … Read more

Could not find a part of the path … bin\roslyn\csc.exe

I am trying to run Asp.net MVC project retrieved from TFS source control. I have added all assembly references and I am able to build and compile successfully without any error or warning. But I get the following error in the browser: Could not find a part of the path ‘C:\B8akWorkspace\B8akProject\B8akSolution\B8AK.Portal\bin\roslyn\csc.exe’. Here is a full … Read more

JavaScriptSerializer – JSON serialization of enum as string

I have a class that contains an enum property, and upon serializing the object using JavaScriptSerializer, my json result contains the integer value of the enumeration rather than its string “name”. Is there a way to get the enum as a string in my json without having to create a custom JavaScriptConverter? Perhaps there’s an … Read more