Tag Archives: methods

how to call two Methods in .Ashx class separately in JavaScript souce:?

Questions: I have a void method ProcessRequest public void ProcessRequest(HttpContext context) { string term = context.Request[“term”] ?? “”; List<string> listAddress = new List<string>(); string cs = ConfigurationManager.ConnectionStrings[“DBCS”].ConnectionString; using (SqlConnection con = new SqlConnection(cs)) { SqlCommand cmd = new SqlCommand(“spGetAddressByindex”, con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter() { ParameterName = “@term”, Value = term }); con.Open(); SqlDataReader… Read More »

Static extension methods [duplicate]

Questions: Possible Duplicate: Can I add extension methods to an existing static class? Is there any way I can add a static extension method to a class. specifically I want to overload Boolean.Parse to allow an int argument. Answers:

Why is AsyncStateMachine created for synchronous methods?

Questions: Imagine the following code: public async Task<int> AsyncMethod() { return 42; } I decompiled this code using SharpLab and noticed that an AsyncStateMachine gets created. But why is this the case for a method lacking an await operator? In my understanding, this method can only run synchronously and the compiler notices the absence of… Read More »

Are .net SqlDataReader methods culture invariant

Questions: I can’t really find a definitive answer to what happens if for example my decimals are stored in the database with different culture settings and I want to get them via a SqlDataReader into my program. Will the ‘,’ and ‘.’ always be correctly parsed and converted to my current culture as long as… Read More »

How to keep methods collapsed in Android Studio?

Questions: I have a project which contains 15 classes. If I collapse the methods and restart Android Studio, everything works fine but if I sync the build.gradle file and restart Android Studio again, the methods from some classes are not collapsed anymore. This is happening not in all classes in my project just in those… Read More »

Understanding differences in common Update Methods on Generic Repository with Entity Framework

Questions: I see 2 common ways people build generic repositories on top of Entity Framework. The generic repository example on docs.microsoft.com uses method 1. https://docs.microsoft.com/en-us/aspnet/mvc/overview/older-versions/getting-started-with-ef-5-using-mvc-4/implementing-the-repository-and-unit-of-work-patterns-in-an-asp-net-mvc-application Method 1: public void Update(T entity) { DbSet.Attach(entity); Context.Entry(entity).State = EntityState.Modified; } Method 2: public void Update(T entity) { Context.Entry(entity).State = EntityState.Modified; } What purpose does the DbSet.Attach(entity) serve in… Read More »

What do querySelectorAll, getElementsByClassName and other getElementsBy* methods return?

Questions: Do getElementsByClassName (and similar functions like getElementsByTagName and querySelectorAll) work the same as getElementById or do they return an array of elements? The reason I ask is because I am trying to change the style of all elements using getElementsByClassName. See below. //doesn’t work document.getElementsByClassName(‘myElement’).style.size = ‘100px’; //works document.getElementById(‘myIdElement’).style.size = ‘100px’; Answers: