What is the difference between const and readonly in C#? When would you use one over the other? 3 31
Given the following class public class Foo { public int FooId { get; set; } public string FooName { get; set; } public ...
-
April 12, 2022
- 0 Comments
I wrote some code for testing the impact of try-catch, but seeing some surprising results. static void Main(string...
When planning out my programs, I often start with a chain of thought like so: A football team is just a list of ...
-
April 11, 2022
- 0 Comments
Given a specific DateTime value, how do I display relative time, like: 2 hours ago 3 days ago a month ago 4 41
From time to time I see an enum like the following: [Flags] public enum Options { None = 0, Option1 = 1, Option2 ...
-
April 11, 2022
- 0 Comments
I want to implement dependency injection (DI) in ASP.NET Core. So after adding this code to ConfigureServices method, both ways work. What is ...
-
April 11, 2022
- 0 Comments
This question already has answers here: Closed 9 years ago. This question already has an answer here: How do I enumerate an enum ...
-
April 11, 2022
- 0 Comments
If I inherit from a base class and want to pass something from the constructor of the inherited class to the constructor of ...
-
April 11, 2022
- 0 Comments
I’ve seen many people use the following code: Type t = typeof(obj1); if (t == typeof(int)) // Some code here But I know ...
-
April 11, 2022
- 0 Comments