developer

C# naming convention for constants?

Question: ❓❓❓ private const int THE_ANSWER = 42; or private const int theAnswer = 42; Personally I think with modern IDEs we should go with camelCase as ALL_CAPS looks strange. What do you think? Good Answer: 👌👌👌 The recommended naming and capitalization convention is to use Pascal casing for constants Read more…

By admin, ago
developer

C# List to string with delimiter

Question: ❓❓❓ Is there a function in C# to quickly convert some collection to string and separate values with delimiter? For example: List<string> names –> string names_together = "John, Anna, Monica" Good Answer: 👌👌👌 You can use String.Join. If you have a List<string> then you can call ToArray first: List<string> Read more…

By admin, ago
developer

Why is JsonRequestBehavior needed?

Question: ❓❓❓ Why is Json Request Behavior needed? If I want to restrict the HttpGet requests to my action I can decorate the action with the [HttpPost] attribute Example: [HttpPost] public JsonResult Foo() { return Json("Secrets"); } // Instead of: public JsonResult Foo() { return Json("Secrets", JsonRequestBehavior.AllowGet); } Why isn’t Read more…

By admin, ago
developer

The breakpoint will not currently be hit. No symbols have been loaded for this document in a Silverlight application

Question: ❓❓❓ Ok, what I have: Visual Studio 2010 RC, W7 x64, started a new project type of Silverlight application. Hosting the Silverlight application in a ASP.NET Web Application Project. Silverlight Version 3.0. Added a LinqToSQL Class, a WCF Service, a Winform Tester Application (Project in the Solution) and a Read more…

By admin, ago
developer

Switch statement fallthrough in C#?

Question: ❓❓❓ Switch statement fallthrough is one of my personal major reasons for loving switch vs. if/else if constructs. An example is in order here: static string NumberToWords(int number) { string[] numbers = new string[] { "", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" }; string[] tens = Read more…

By admin, ago