Enumerate All the Values in an Enum
See an easy way to enumerate all the values. public enum WorkTypes{Remote = 0,Office = 1,Exempted = 2}foreach (WorkTypes workType in Enum.GetValues(typeof(WorkTypes)))Console.WriteLine(workType);
See an easy way to enumerate all the values. public enum WorkTypes{Remote = 0,Office = 1,Exempted = 2}foreach (WorkTypes workType in Enum.GetValues(typeof(WorkTypes)))Console.WriteLine(workType);
The Microsoft.AspNetCore.Http.StatusCodes?enum has many response codes. Please see below for an example to return one of the values from the enum: [HttpGet]public IActionResult CustomStatusCode (){ //code”return StatusCode(Microsoft.AspNetCore.Http.StatusCodes.Status405MethodNotAllowed);}
Visual Studio allows you to communicate with fellow developers about a piece of code. It lets you add a compiler directive “warning” to your code, which shows up in the
You can use the SHA1Managed class and compute hash for an input string as shown below. It is done in two steps. First, is to get the byte array after
Oftentimes, the input is an integer that has to be converted to the appropriate enum value. All we have to do is cast the integer value as below: EnumName e
The BitConvertor class can convert a byte array to a string in C#, as shown below: string convertedValue = BitConverter.ToString(byteArray).Replace(“-“,””);
We often create console applications to write test code or to do quick experiments in Visual Studio because they are lightweight when compared to Windows/Web applications. Visual Studio 2015 provides
There are lot of .NET helper assemblies that help you represent datetime in more readable formats, such as yesterday, 5 minutes ago, and so on. One of the libraries that
You can use HttpResponse’s IsClientConnected property to figure out if the connection is still alive. Based on the value, you can kill a long-running process if the client is not